Skip to content

Instantly share code, notes, and snippets.

@naviocean
Last active February 12, 2023 13:16
Show Gist options
  • Save naviocean/ebbe0139daa9a890c4a3bd0c45024ddb to your computer and use it in GitHub Desktop.
Save naviocean/ebbe0139daa9a890c4a3bd0c45024ddb to your computer and use it in GitHub Desktop.
Install Nvidia Driver, Cuda, Cudnn on ubuntu

1. Install NVIDIA Driver Version 390 via apt-get

sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-390 nvidia-modprobe

To verify installation, restart your machine with reboot and type nvidia-smi.

2. Install Cuda 9.0

The CUDA runfile installer can be downloaded from NVIDIA’s website. Choose the runfile option. Choose the deb (local) option. Download and follow installation instructions:

sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
sudo apt-key add /var/cuda-repo-<version>/7fa2af80.pub
sudo apt-get update
sudo apt-get install cuda

3. Install cuDNN 7.3.1

Go to the cuDNN download page (need registration) and select the latest cuDNN 7.3.1 version made for CUDA 9.0. Download all 3 .deb files: the runtime library, the developer library, and the code samples library for Ubuntu 16.04. In your download folder, install them in the same order:]

sudo dpkg -i libcudnn7_7.3.1.20-1+cuda9.0_amd64.deb (the runtime library),

sudo dpkg -i libcudnn7-dev_7.3.1.20–1+cuda9.0_amd64.deb (the developer library), and

sudo dpkg -i libcudnn7-doc_7.3.1.20–1+cuda9.0_amd64.deb (the code samples).

Now we can verify the cuDNN installation (below is just the official guide, which surprisingly works out of the box):

Copy the code samples somewhere you have write access: cp -r /usr/src/cudnn_samples_v7/ ~.

Go to the MNIST example code: cd ~/cudnn_samples_v7/mnistCUDNN.

Compile the MNIST example: make clean && make.

Run the MNIST example: ./mnistCUDNN. If your installation is successful, you should see Test passed! at the end of the output.

4. Install NCCL

Go to NCCL download page and select latest version 2.3.5 for CUDA 9.0 Download deb file and run command:

sudo dpkg -i nccl-repo-ubuntu1604-2.3.5-ga-cuda9.0_1-1_amd64.deb

sudo apt update

sudo apt install libnccl2 libnccl-dev

5. Setup env

  1. Create a new file myenv.sh and move it into /etc/profile.d
sudo nano /etc/profile.d/myenv.sh
  1. Set content
#!/bin/sh
export CUDA_HOME=/usr/local/cuda
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$CUDA_HOME/extras/CUPTI/lib64:$LD_LIBRARY_PATH
export INCLUDE_PATH=$CUDA_HOME/include:$INCLUDE_PATH
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment