Skip to content

Instantly share code, notes, and snippets.

@eherrerosj
Last active July 1, 2020 10:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eherrerosj/7c884d2d434a4b708af9887ddaaa517a to your computer and use it in GitHub Desktop.
Save eherrerosj/7c884d2d434a4b708af9887ddaaa517a to your computer and use it in GitHub Desktop.
Installing NVIDIA driver and CUDA 9.1 on Ubuntu
### Nvidia installation reference: https://gist.github.com/wangruohui/df039f0dc434d6486f5d4d098aa52d07#install-nvidia-graphics-driver-via-apt-get
sudo apt-get purge nvidia*
# Note this might remove your cuda installation as well
sudo apt-get autoremove
# Recommended if .deb files from NVIDIA were installed
# Change 1404 to the exact system version or use tab autocompletion
# After executing this file, /etc/apt/sources.list.d should contain no files related to nvidia or cuda
sudo dpkg -P cuda-repo-ubuntu1404
sudo apt-get install htop build-essential terminator dkms
sudo nano /etc/modprobe.d/blacklist-nouveau.conf
sudo update-initramfs -u
sudo reboot
# log in again and execute this
sudo systemctl stop lightdm
cd ~
wget http://us.download.nvidia.com/XFree86/Linux-x86_64/390.25/NVIDIA-Linux-x86_64-390.25.run
chmod +x NVIDIA-Linux-x86_64-390.25.run
sudo ./NVIDIA-Linux-x86_64-390.25.run --dkms -s
# check we have connection with the gpu
nvidia-smi
cd ~
wget https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux.run
# if the previous fails download manually from https://developer.nvidia.com/compute/cuda/9.1/Prod/local_installers/cuda_9.1.85_387.26_linux
chmod +x cuda_9.1.85_387.26_linux.run
./cuda_9.1.85_387.26_linux.run --extract=$HOME
cd ~
sudo ./cuda-linux.9.1.85-23083092.run
sudo bash -c "echo /usr/local/cuda/lib64/ > /etc/ld.so.conf.d/cuda.conf"
sudo ldconfig
# sudo nano /etc/environment and add /usr/local/cuda/bin to the path string
tar -xzvf cudnn-9.0-linux-x64-v7.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h
/usr/local/cuda/lib64/libcudnn*
# forget about the next 2 lines if you don't have a Mac keyboard
sudo apt-get install keyboard-configuration
sudo dpkg-reconfigure keyboard-configuration
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment