Skip to content

Instantly share code, notes, and snippets.

@moroclash
Forked from morgangiraud/nvidia-reinstall.sh
Last active December 8, 2018 23:26
Show Gist options
  • Save moroclash/513271ac75129f51e439dc134a23836c to your computer and use it in GitHub Desktop.
Save moroclash/513271ac75129f51e439dc134a23836c to your computer and use it in GitHub Desktop.
Script to reinstall manually nvidia drivers,cuda 9.0 and cudnn 7.1 on Ubuntu 16.04
# Remove anything linked to nvidia
sudo apt-get remove --purge nvidia*
sudo apt-get autoremove
#install important lib's
sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy python3-numpy build-essential python-pip python3-pip python-virtualenv swig python-wheel libcurl3-dev curl python python3 gcc g++
# Search for your driver
apt search nvidia
#Note :: should instal latest driver it's nvidia-396
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
# Select one driver (the last one is a decent choice)
sudo apt install nvidia-396
# Test the driver
sudo shutdown -r now
nvidia-smi
# If it doesn't work, sometimes this is due to a secure boot option of your motherboard, disable it and test again
# Install cuda
#ctrl + alt + f1 to close Xserver ..
#log in
#install coda
#*option 1
# download cuda*.run
# sudo chmod +x cuda*.run
# sudo ./cuda*.run
#*option 2
# Get your deb cuda file from https://developer.nvidia.com/cuda-downloads
sudo dpkg -i dev.file
sudo apt update
sudo apt install cuda
# Add cuda to your PATH and install the toolkit
# Also add them to your .bashrc file
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_HOME=/usr/local/cuda-9.0
nvcc --version
# Use the toolkit to check your CUDA capable devices
cuda-install-samples-9.0.sh ~/.
cd ~/NVIDIA_CUDA-9.0_Samples/1_Utilities/deviceQuery
make
shutdown -r now
# Test cuda
cd ~/NVIDIA_CUDA-9.0_Samples/1_Utilities/deviceQuery
./deviceQuery
# Downloads cudnn deb files from the nvidia website:
# https://developer.nvidia.com/rdp/cudnn-download
# Install cudnn
tar -zxvf cudnn-9.0-linux-x64-v5.1.tgz
sudo mv cuda/include/* /usr/local/cuda-9.0/include/.
sudo mv cuda/lib64/* /usr/local/cuda-9.0/lib64/.
# Reload your shell
. ~/.bashrc
@MoustafaAMahmoud
Copy link

please change the below line for ubuntu 18.04
from
sudo apt install nvidia-396
to
sudo apt install nvidia-driver-396

@MoustafaAMahmoud
Copy link

Please remove /usr/local/cuda-9.0/ make it just /usr/local/cuda

also, remove 9.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment