How To Install NVIDIA CUDA Deep Neural Network library (cuDNN) on Ubuntu


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.

Deep learning researchers and framework developers worldwide rely on cuDNN for high-performance GPU acceleration. It allows them to focus on training neural networks and developing software applications rather than spending time on low-level GPU performance tuning. 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.


Prerequisites

Ensure you meet the following requirements before you install cuDNN.
  • A GPU of compute capability 3.0 or higher. To understand the compute capability of the GPU on your system, see: CUDA GPUs. Also see the cuDNN Support Matrix.
  • If you are using cuDNN with a Volta GPU, version 7 or later is required.
  • One of the following supported Architecture - OS combinations:
  • On x86_64 (for installing cuDNN with debian files)
  • Ubuntu 14.04 or
  • Ubuntu 16.04
  • On x86_64 (for installing tgz files)
  • Any Linux distribution
  • On POWER8/POWER9
  • RHEL7.4, and Ubuntu 16.04

One of the following supported CUDA versions and NVIDIA graphics driver:
  • NVIDIA graphics driver R418 or newer for CUDA 10.1
  • 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

For more information, see

Downloading cuDNN

In order to download cuDNN, ensure you are registered for the NVIDIA Developer Program.

  1. Go to: NVIDIA cuDNN home page.
  2. Click Download.
  3. Complete the short survey and click Submit.
  4. Accept the Terms and Conditions. A list of available download versions of cuDNN displays.
  5. Select the cuDNN version you want to install. A list of available resources displays.
I have NVIDIA graphics driver R415 and CUDA 10.0.130, so I select cuDNN v7.5.0 for CUDA 10.0 -> cuDNN Library for Linux


Installing cuDNN on Linux (Ubuntu)

The following steps describe how to build a cuDNN dependent program. Choose the installation method that meets your environment needs. For example, the tar file installation applies to all Linux platforms, and the debian installation package applies to Ubuntu 14.04, 16.04 and 18.04.

In the following sections:
  • your CUDA directory path is referred to as /usr/local/cuda/
  • your cuDNN download path is referred to as <cudnnpath>

Case 1: Installing from a Tar File

    1. Navigate to your <cudnnpath> directory containing the cuDNN Tar file.
    2. Unzip the cuDNN package.
tar -xzvf cudnn-10.0-linux-x64-v7.5.0.56.tgz



    3. Copy the following files into the CUDA Toolkit directory, and change the file permissions.

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*



Case 2: Installing from a Debian File

    1. Navigate to your <cudnnpath> directory containing cuDNN Debian file.
    2. Install the runtime library, for example:
sudo dpkg -i libcudnn7_7.5.0.56-1+cuda10.0_amd64.deb
    3. Install the developer library, for example:
sudo dpkg -i libcudnn7-dev_7.5.0.56-1+cuda10.0_amd64.deb
    4. Install the code samples and the cuDNN Library User Guide, for example:
sudo dpkg -i libcudnn7-doc_7.5.0.56-1+cuda10.0_amd64.deb

Verifying

To verify that cuDNN is installed, you can check by command:
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2


To verify that cuDNN is running properly, compile the mnistCUDNN sample located in the /usr/src/cudnn_samples_v7 directory in the debian file (you need to install the code samples and the cuDNN Library User Guide before, see step 4 Case 2: Installing from a Debian File).

    1. Copy the cuDNN sample to a writable path.
cp -r /usr/src/cudnn_samples_v7/ $HOME
    2. Go to the writable path.
cd  $HOME/cudnn_samples_v7/mnistCUDNN
    3. Compile the mnistCUDNN sample.
make clean && make
    4. Run the mnistCUDNN sample.
./mnistCUDNN
If cuDNN is properly installed and running on your Linux system, you will see a message similar to the following:
Test passed!


Upgrading from v6 to v7

cuDNN v7 can coexist with previous versions of cuDNN, such as v5 or v6.

Troubleshooting

Join the NVIDIA Developer Forum to post questions and follow discussions.

Good Luck!


Post a Comment

0 Comments