Skip to content

Latest commit

 

History

History
116 lines (75 loc) · 4.21 KB

README.md

File metadata and controls

116 lines (75 loc) · 4.21 KB

NVIDIA Driver, CUDA 11.4, cuDNN v8.2.4 installation on Ubuntu 20.04

Uninstall previous versions

  • First of all remove all related versions of NVIDIA driver, CUDA and cuDNN by executing the following commands.
sudo apt-get --purge remove "*cuda*" "*cublas*" "*cufft*" "*cufile*" "*curand*" \
 "*cusolver*" "*cusparse*" "*gds-tools*" "*npp*" "*nvjpeg*" "nsight*" "*nvvm*"
sudo apt-get --purge remove "*nvidia*" "libxnvctrl*"
sudo rm -rf /usr/local/cuda*
sudo apt autoremove

Installation of NVIDIA Drivers, CUDA and cuDNN

NVIDIA Drivers

Install CUDA matching NVIDIA Driver version

  • In this tutorial, I am going to install CUDA 11.4.3 (Although 11.5 is the latest one at the time of writing this tutorial).
wget https://developer.download.nvidia.com/compute/cuda/11.4.3/local_installers/cuda_11.4.3_470.82.01_linux.run
  • After running the below command, make sure that you uncheck NVIDIA Driver option (as shown below) as we have already installed it in the previous step.

    Info: To install a specific version of the cuda toolkits go to https://developer.nvidia.com/cuda-toolkit-archive

    Note: Some versions not officially supported ubuntu 20.04 due to lack of some prerequisites, you can override the install-time prerequisite checks by running the installer with the flag. Remember that the prerequisites will still be required to use the NVIDIA CUDA Toolkit -override

    sudo sh cuda_11.4.3_470.82.01_linux.run

    Replace cuda_* with the file you downloaded.

  • After successful installation, you will get a warning message (as shown below) that it did not install CUDA Driver, just ignore it as we had installed it separately before.

Add CUDA path to the bashrc file

  • For programs to be able to recognize the location of CUDA, we must add PATH to the bashrc file. Execute the following commands to add CUDA path.
echo 'export PATH=/usr/local/cuda-11.4/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-11.4/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
source ~/.bashrc
sudo ldconfig

Installation of cuDNN matching CUDA version

  • Installation of cuDNN is highly recommended to speed up calculations further. You must have an NVIDIA account to download cuDNN. Please create your account before downloading.

  • Download cuDNN from here: https://developer.nvidia.com/rdp/cudnn-archive

- In this tutorial, I am going to install `cuDNN v8.2.4` for `CUDA 11.4`.
  • There are several ways to install cuDNN but the simplest is to download the compressed file and extract to relevant CUDA directory.
tar -xzvf ${CUDNN_TAR_FILE}
sudo cp -P cuda/include/cudnn.h /usr/local/cuda-11.4/include
sudo cp -P cuda/lib64/libcudnn* /usr/local/cuda-11.4/lib64/
sudo chmod a+r /usr/local/cuda-11.4/lib64/libcudnn*

Verify Installation

  • If you followed the above steps correctly, NVIDIA drivers, CUDA and cuDNN should have installed correctly.

  • Execute nvidia-smi and nvcc --version to see if everything is working as expected and the CUDA versions match for them.

nvidia-smi

nvcc --version

Issues

Feel free to open issues if you face any problem. Thank you!