OSETC TECH

How to Install NVIDIA cuDNN on Ubuntu 16.04/18.04 Linux

This post will guide you how to install cuDNN on your Ubuntu Linux server. How do I install the latest version of cuDNN and check for correct operation of NIDIA cuDNN on Ubuntu 16.04 or 18.04 Linux.

What is cuDNN?


The NVIDIA CUDA Deep Neural Network library (cuDNN) is a GPU-accelerated library of primitives for deep neural networks. cuDNN provides highly tuned implementations for standard routines such as forward and backward convolution, pooling, normalization, and activation layers. cuDNN is part of the NVIDIA Deep Learning SDK. It can be used for high-performance GPU acceleration. cuDNN accelerates widely used deep learning frameworks, including Caffe, Caffe2, TensorFlow, Theano, Torch, PyTorch, MXNet, and Microsoft Cognitive Toolkit. cuDNN is freely available to members of the NVIDIA Developer Program.

Prerequisties


Before installing cuDNN tool, you need to make sure that your system match the following requirements:

NVIDIA graphics driver R410 or newer for CUDA 10.0
NVIDIA graphics driver R396 or newer for CUDA 9.2
NVIDIA graphics driver R384 or newer for CUDA 9
NVIDIA graphics driver R375 or newer for CUDA 8

So you also need to make sure that the latest NVIDIA graphics driver and CUDA Toolkit are installed on your system.

Installing cuDNN


Step1: Installing the Latest NVIDIA Graphics Drivers

You need to install the latest NVIDIA graphics drivers on your system based on your actual NVIDIA hardware before installing cuDNN, just do the following steps:

#1 you can go to the official download web page of NVIDIA to download the latest NVIDIA graphics driver.

#2 select Product Type and Operating System from the drop down menu list. click SEARCH button.

#3 clicking on Download button to download the driver to your local disk. or you can use the wget command to get the driver file. type:

$ wget https://www.nvidia.com/content/DriverDownload-March2009/confirmation.php?url=/XFree86/Linux-x86_64/418.43/NVIDIA-Linux-x86_64-418.43.run

#4 installing the downloaded NVIDIA graphics driver with the following command:

$ sudo ./NVIDIA-Linux-x86_64-418.43.run

#5 after installed drivers, you need to reatart your system to ensure the NVIDIA graphics driver takes effect.

Step2: Installing CUDA Toolkit

Before installing cuDNN, you also need to install CUDA Toolkit on your system, and we have explained that how to install CUDA toolkit on Ubuntu system in the previous post.

Step3: Downloading cuDNN

To download cuDNN to your local disk, you need to do the following steps:

#1 you need to register for the NVIDIA Developer Program firstly.

#2 go the NVIDIA cuDNN home page, click Download button, and then you need to complete the short survey and click Submit.

#3 you should see a list of available download versions of cuDNN displays, you need to choose one based on CUDA version installed on your system. For example, if you have installed CUDA 10.1 on your Ubuntu system, you should choose the first one.

#4 You can download a tar file or deb files with the following commands:

$ wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.5.0.56/prod/10.1_20190225/cudnn-10.1-linux-x64-v7.5.0.56.tgz

Or

$ wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.5.0.56/prod/10.1_20190225/Ubuntu18_04-x64/libcudnn7_7.5.0.56-1%2Bcuda10.1_amd64.deb

$ wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.5.0.56/prod/10.1_20190225/Ubuntu18_04-x64/libcudnn7-dev_7.5.0.56-1%2Bcuda10.1_amd64.deb

$wget https://developer.nvidia.com/compute/machine-learning/cudnn/secure/v7.5.0.56/prod/10.1_20190225/Ubuntu18_04-x64/libcudnn7-doc_7.5.0.56-1%2Bcuda10.1_amd64.deb

Step 4: Installing cuDNN from a Tar File

If you are using a Linux system, such as: CentOS or Ubuntu Linux, you can try to install cuDNN tool from a tar file, just do the following steps:

#1 extract all files from cuDNN tar package with the following steps:

$ tar -zxvf cudnn-10.1-linux-x64-v7.5.0.56.tgz

#2 you need to copy the following files into the CUDA Toolkit directory with the following commands:

$ sudo cp cuda/include/cudnn.h /usr/local/cuda/include
$ sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64

#3 change the file permissions for those files, type:

$ sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*

Step 5: Installing cuDNN from a Deb File

If you are using Debian or Ubuntu Linux, you can use dpkg command to install those above deb files, type:

$ sudo dpkg -i libcudnn7_7.0.3.11-1+cuda9.0_amd64.deb

$ sudo dpkg -i libcudnn7-devel_7.0.3.11-1+cuda9.0_amd64.deb

$ sudo dpkg -i libcudnn7-doc_7.0.3.11-1+cuda9.0_amd64.deb

Note: the first command will install the Runtime library, the second command will install the developer library, and the third command will install the code samples and the cuDNN Libray User Guide.

Conclusion


You should know that how to install cuDNN tool on Ubuntu 16.04 or 18.04 from this guide, and you also know how to install cuDNN with the different methods on Ubuntu Linux server(tar file or deb file). If you want to see more information about cuDNN, you can go the official web site of cuDNN directly.