Install Nvidia Driver on Ubuntu 20.04
Install driver and CUDA
I don’t recommend installing the NVIDIA drivers that come with CUDA as they do not contain the dkms drivers that carry over into new kernel upgrades.
The Ubuntu repositories now contain the same drivers as the graphics-drivers PPA. So feel free to install the 495.44 drivers.
1 | sudo apt install nvidia-driver-495 |
Reboot the system so the new driver takes effect.
Now, download the CUDA 11.5.0 .run file from NVIDIA:
1 | wget https://developer.download.nvidia.com/compute/cuda/11.5.0/local_installers/cuda_11.5.0_495.29.05_linux.run |
Run the .run file as sudo:
1 | sudo sh ./cuda_11.5.0_495.29.05_linux.run |
If you get the following, just choose Continue:
1 | ┌──────────────────────────────────────────────────────────────────────────────┐ |
Accept the EULA:
1 | ┌──────────────────────────────────────────────────────────────────────────────┐ |
Unselect the video driver by pressing the spacebar while [X] Driver is highlighted:
1 | ┌──────────────────────────────────────────────────────────────────────────────┐ |
Then press the down arrow to Install. Press Enter then wait for installation to complete.
After the installation is complete add the following to the bottom of your ~/.profile or add it to the /etc/profile.d/cuda.sh file which you might have to create for all users (global):
1 | # set PATH for cuda 11.5 installation |
Install libcudnn8
Add the Repo:
NOTE: The 20.04 repo from NVIDIA does not supply libcudnn but the 18.04 repo does and installs just fine into 20.04.
1 | echo "deb http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" | sudo tee /etc/apt/sources.list.d/cuda_learn.list |
Install the key:
1 | sudo apt-key adv --fetch-keys http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/7fa2af80.pub |
Update the system:
1 | sudo apt update |
Install libcudnn 8.0.4:
1 | sudo apt install libcudnn8 |
I recommend now to reboot the system for the changes to take effect.
After it reboots check the installations using nvidia-smi
and check CUDA install with nvcc --version
and check libcudnn install:
1 | ~$ /sbin/ldconfig -N -v $(sed 's/:/ /' <<< $LD_LIBRARY_PATH) 2>/dev/null | grep libcudnn |
Visit https://askubuntu.com/questions/1077061/how-do-i-install-nvidia-and-cuda-drivers-into-ubuntu/1077063#1077063 for detailed step on installing Nvidia driver on Ubuntu 18.04