
CUDA Deep Neural Network (cuDNN) is an NVIDIA library that enables GPU-accelerated computations for deep neural networks. By installing cuDNN on Ubuntu, developers can directly invoke functions to train and run inference on neural networks without having to write the base functions. Neural networks are the building blocks of most modern deep learning applications, such as generative AI models.
This guide explains how to install the NVIDIA cuDNN library on a Ubuntu 22.04 server.
Before you begin:
Deploy a fresh Ubuntu 22.04 Server on Vultr
Create an NVIDIA developer account to download the cuDNN package
Using SSH, access the server
Create a non-root user with sudo privileges
Switch to the new non-root user account. Replace pythonuser with your desired username
To install cuDNN on Ubuntu, you can either use an archived release file or Conda. It's recommended to use the release file as it offers more stability and does not overwrite any system files. Depending on your choice, install cuDNN as described in the steps below.
In this section, install cuDNN version 8.9.4 for the CUDA version 12.x natively using the official release file.
Using a web browser such as Chrome, visit the cuDNN download page
Agree to the cuDNN license agreement
Click the Download cuDNN, for CUDA resource link
In the open dropdown dialog, click the Local Installer for Linux x86_64 (Tar) link to download the latest release file to your computer
You can download a
.debrelease file, but it may overwrite system files upon installation
This article uses the cuDNN version 8.9.4 for CUDA 12.x with the following filename
In a new terminal window, switch to your downloads directory
Using a secure transfer protocol such as SCP, upload the cuDNN release file to your remote server
Replace pythonuser and SERVER-IP with your actual Vultr server details
When the transfer is successful, navigate to your SSH session and switch to your user home directory
Long list files in the directory
Output:
Verify that the cuDNN release file is available
Extract files from the cuDNN release file
Copy the cuDNN header files to the CUDA include directory
Copy the cuDNN library files to the CUDA library
Change the library files directory permissions to grant all system users read access to the directory
To install cuDNN using Conda on Ubuntu, verify the latest supported version that matches the CUDA version number. In this section, install cuDNN version 8.9.2.26 for CUDA 11.x using Conda as described below.
Using Conda, install the CUDA toolkit version 11.8.0
When installed, follow the Post-installation steps to activate the CUDA Toolkit on your server
Install the latest cuDNN version from the default channel
To install a specific version from a particular channel, use the command syntax conda install cudnn=="x.y.z.w" -c channel-name. The above command installs the cuDNN version 8.9.2.26 from the default channel.
To test your cuDNN installation, download and run the NVIDIA verification program using the .deb release file as described below.
Local installer for Ubuntu22.04 x86_64 (Deb) file link to download the file on your computerThis article uses the cuDNN version 8.9.4 with the following filename
In a new terminal session, switch to your downloads file directory
Using SCP, upload the file to your remote server
In your SSH session, switch to your user's home directory
Install the required dependency libraries
Long list files in the directory
Verify that the .deb file is available
Create a new temporary directory such as deb
Move the uploaded .deb installer package to the directory
Switch to the directory
Using the ar utility, extract the contents from the deb file
When the extraction is successful, long list files in the directory
Output:
Verify that a new data.tar.xz is available
Extract files from the data.tar.xz archive
When the extraction is complete, the etc, usr, and var subdirectories are added to the directory.
Switch to the cudnn-local-repo-ubuntu2204-8.9.4.25 sub-directory within the var directory
Within the directory, extract files from the libcudnn8-samples_8.9.4.25-1+cuda12.2_amd64.deb file
Extract files from the new data.tar.xz archive file
When the extraction is complete, switch to the new usr directory that contains source code, and sample program files
Switch to the mnistCUDNN program directory
Clean any previous build artifacts
Compile the MNIST program
When successful, your output should look like the one below:
If the command returns compilation errors, run the mnistCUDNN instead
When successful, your output should look like the one below:
When the test is successful, cuDNN is active and installed on your server
To successfully install and use cuDNN on your server, verify that the following necessary drivers and minimum required versions are available on the system:
Verify the installed drivers and versions on your system to use cuDNN as described in the following sections.
NVIDIA GPU Drivers are essential for the system to access and use the GPU. On Vultr Cloud GPU servers, the drivers are pre-installed during system initialization. When installing NVIDIA cuDNN, verify if the NVIDIA GPU drivers are correctly installed using the following command
Applications that use cuDNN require the CUDA Toolkit to work correctly. Verify if the CUDA compiler is available on your server using the following command
Your output should look like the one below:
As displayed in the above output, the CUDA 12.x. version is available on the system
cuDNN requires a recent kernel version to work on your system. The kernel version must be more recent than the minimum version required by the cuDNN version you intend to install. Run the following command to view the available kernel version on your system
Output:
The above output displays the installed kernel version 5.15.0-75
The GNU Compiler Collection (GCC) is necessary when compiling application programs. To use cuDNN, your system must have a GCC version higher than the required cuDNN version.
Verify the installed GCC version
Your output should look like the one below:
As displayed in the above output, the GCC version 11.3.0 is available on the server
In this guide, you installed the NVIDIA cuDNN package on a Ubuntu 22.04 server using two options, native and Conda. You also verified the system configuration to install the matching cuDNN version. For more information about cuDNN, visit the official documentation. To develop applications using cuDNN, visit the cuDNN API Reference that discusses the available cuDNN functions such as routines for training and inference using neural networks.
0 Comments
Be the first to comment and share your perspective with the community.