Skip to content

Instantly share code, notes, and snippets.

@rahulbhadani
Last active May 1, 2021 04:26
Show Gist options
  • Save rahulbhadani/68dfdac630a6b821b91bd29e066a6835 to your computer and use it in GitHub Desktop.
Save rahulbhadani/68dfdac630a6b821b91bd29e066a6835 to your computer and use it in GitHub Desktop.
NVIDIA Installation

Installation

wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
sudo mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600

wget https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda-repo-ubuntu2004-11-3-local_11.3.0-465.19.01-1_amd64.deb
sudo dpkg -i cuda-repo-ubuntu2004-11-3-local_11.3.0-465.19.01-1_amd64.deb

sudo apt-key add /var/cuda-repo-ubuntu2004-11-3-local/7fa2af80.pub
sudo apt-get update

sudo apt-get -y install cuda
export PATH=/usr/local/cuda-11.3/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Some checks:

systemctl status nvidia-persistenced
sudo systemctl enable nvidia-persistenced
cat /proc/driver/nvidia/version

Output is :

NVRM version: NVIDIA UNIX x86_64 Kernel Module  465.19.01  Fri Mar 19 07:44:41 UTC 2021
GCC version:  gcc version 9.3.0 (Ubuntu 9.3.0-17ubuntu1~20.04)

Download following files from NVIDIA's Developer page for cuDNN:

  1. libcudnn8-samples_8.2.0.53-1+cuda11.3_amd64.deb
  2. libcudnn8-dev_8.2.0.53-1+cuda11.3_amd64.deb
  3. libcudnn8_8.2.0.53-1+cuda11.3_amd64.deb

You will need to create a developer's account at Nvidia to download these deb files. Next, install .deb files:

sudo dpkg -i  libcudnn8_8.2.0.53-1+cuda11.3_amd64.deb
sudo dpkg -i libcudnn8-dev_8.2.0.53-1+cuda11.3_amd64.deb
sudo dpkg -i libcudnn8-samples_8.2.0.53-1+cuda11.3_amd64.deb

OS=ubuntu2004
echo $OS
wget https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/cuda-${OS}.pin
sudo mv cuda-${OS}.pin /etc/apt/preferences.d/cuda-repository-pin-600
sudo apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/7fa2af80.pub
sudo add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/ /"
sudo apt-get update
cudnn_version=8.1.1.*
cuda_version=cuda11.2
sudo apt-get install libcudnn8=${cudnn_version}-1+${cuda_version}
c

Disabling secure boot

You need to disable secure boot

sudo mokutil --disable-validation

This will ask you to enter password. Reboot. Then enter password. Usually, system will ask you to specific letter of your password.

Then run following command after reboot is finished and you login back to Ubuntu:

nvidia-smi

It's output will be:

Fri Apr 30 21:19:53 2021       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 465.19.01    Driver Version: 465.19.01    CUDA Version: 11.3     |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|                               |                      |               MIG M. |
|===============================+======================+======================|
|   0  NVIDIA GeForce ...  On   | 00000000:01:00.0 Off |                  N/A |
| N/A   41C    P8     3W /  N/A |    825MiB /  3914MiB |      7%      Default |
|                               |                      |                  N/A |
+-------------------------------+----------------------+----------------------+
                                                                            
+-----------------------------------------------------------------------------+
| Processes:                                                                  |
|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
|        ID   ID                                                   Usage      |
|=============================================================================|
|    0   N/A  N/A      1084      G   /usr/lib/xorg/Xorg                133MiB |
|    0   N/A  N/A      1720      G   /usr/lib/xorg/Xorg                339MiB |
|    0   N/A  N/A      1892      G   /usr/bin/gnome-shell               68MiB |
|    0   N/A  N/A      3439    C+G   ...R2021a/bin/glnxa64/MATLAB      226MiB |
|    0   N/A  N/A      3720      G   ...1531959360FF99E4245683A9B        5MiB |
|    0   N/A  N/A      4966      G   ...AAAAAAAAA= --shared-files       33MiB |
+-----------------------------------------------------------------------------+

Test your installation:

cp -r /usr/src/cudnn_samples_v8/ $HOME
cd $HOME/cudnn_samples_v8/mnistCUDNN/
make
./mnistCUDNN

You will see output Test passed or something similar. Congrats, you have NVIDIA cuDNN library for developing deep learning applications using NVIDIA GPU.

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