Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
NVIDIA CUDA installation and configuration notes

CUDA installation on Ubuntu

WARNING This installation will REPLACE existing Nvidia driver

Download CUDA (tested with CUDA 10) Run commands:

sudo dpkg -i cuda-repo-<version>.deb
sudo apt-key add /var/cuda-repo-<version>/
sudo apt-get update
sudo apt-get install cuda

apt package is also available if you have blazing fast connection. Otherwise downloading deb is much more efficient especially in case of installation on multiple machines

Validating installation by running deviceQuery:

cd /usr/local/cuda/extras/demo_suite

You should see your GPU CUDA details eg.

CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "GeForce 940M"
  CUDA Driver Version / Runtime Version          9.0 / 9.0
  CUDA Capability Major/Minor version number:    5.0
  Total amount of global memory:                 2003 MBytes (2100232192 bytes)
  ( 3) Multiprocessors, (128) CUDA Cores/MP:     384 CUDA Cores
  GPU Max Clock rate:                            1176 MHz (1.18 GHz)
  Memory Clock rate:                             900 Mhz

Add export scripts in ~/.bashrc to run it from everywhere:

export CUDA_HOME="/usr/local/cuda"
export PATH="$PATH:$CUDA_HOME/bin"

apply by running source ~/.bashrc

cuDNN installation on Ubuntu

Download 3 cuDNN files (requires NVIDIA account which can be obtained for free):

  1. cuDNN Runtime Library for Ubuntu (Deb)
  2. cuDNN Developer Library for Ubuntu (Deb)
  3. cuDNN Code Samples and User Guide for Ubuntu (Deb)

Install them:

sudo dpkg -i libcudnnX_<version>_amd64.deb
sudo dpkg -i libcudnnX-dev_<version>_amd64.deb
sudo dpkg -i libcudnnX-doc_<version>_amd64.deb

We can also install using tarball but it won't include code samples and won't allow us to install libcupti-dev which is required by TensorFlow

Validate by running mnistCUDNN and make sure no error:

cd /usr/src/cudnn_samples_v<version>/mnistCUDNN
sudo make clean && sudo make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.