Upgrade CUDA and cuDNN

Remove old version

If your graph drvier supports desire CUDA version, do not need to remove the exsiting driver.
Check the following link: https://docs.nvidia.com/deploy/cuda-compatibility/index.html

To remove CUDA Toolkit:

$ sudo apt-get --purge remove "*cublas*" "*cufft*" "*curand*" \
 "*cusolver*" "*cusparse*" "*npp*" "*nvjpeg*" "cuda*" "nsight*"

To remove NVIDIA Drivers:

$ sudo apt-get --purge remove "*nvidia*"

To clean up the uninstall:

$ sudo apt-get autoremove

From offical document: https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html

Donwload and Install CUDA and cuDNN

CUDA

https://developer.nvidia.com/cuda-11.0-update1-download-archive?target_os=Linux&target_arch=x86_64&target_distro=Ubuntu&target_version=1804&target_type=runfilelocal

During the installation, uncheck graph driver.

# runfile(local)
wget https://developer.download.nvidia.com/compute/cuda/11.0.3/local_installers/cuda_11.0.3_450.51.06_linux.run  
sudo sh cuda_11.0.3_450.51.06_linux.run

Environment Variable Setting

vim ~/.bashrc

export PATH=/usr/local/cuda-11.1/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64:$LD_LIBRARY_PATH

Version Check

nvcc --version

Install cuDNN

The following instruction is based on zip file of linux version.

$ 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*

Conda cudatoolkit의 차이점
conda install cudatoolkit으로 설치된 library는 apt install로 설치된 것과는 다르지만 PyTorch등의 DL Framework에서 필요로 하는 부분들은 모두 담고 있다.
nvcc compiler는 따로 설치 되지 않으므로 필요할 경우 cudatoolkit을 모두 설치해야 할 수 있음.

Check version

# Before cuDNN 8.x
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2

# After cuDNN 8.x
cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2

dpkg 설치시

dpkg -l | grep cuDNN

ii  libcudnn8                                  8.1.0.77-1+cuda11.2                   amd64        cuDNN runtime libraries
ii  libcudnn8-dev                              8.1.0.77-1+cuda11.2                   amd64        cuDNN development libraries and headers
ii  libcudnn8-samples                          8.1.0.77-1+cuda11.2                   amd64        cuDNN documents and samples

dpkg -l | grep CUDA

Change cuDNN version

$ sudo update-alternatives --config libcudnn

There is 1 choice for the alternative libcudnn (providing /usr/include/cudnn.h).

  Selection    Path                                      Priority   Status
------------------------------------------------------------
  0            /usr/include/x86_64-linux-gnu/cudnn_v8.h   80        auto mode
* 1            /usr/include/x86_64-linux-gnu/cudnn_v8.h   80        manual mode

+ Recent posts