Article directory
In the Ubuntu system, you can use nvidia-smi
the command to see the current GPU information, and you can see the CUDA Version in the upper right corner, which means the maximum supported CUDA version number.
In the previous article , the graphics card driver has been installed. This time, continue to install CUDA and cudnn.
To be installed:
cuda 11.7
cuDNN v8.9.0 (for CUDA 11.x)
Install CUDA
Open the official website: https://developer.nvidia.com/cuda-toolkit-archive
Select CUDA 11.7, select "Lunix" and the corresponding architecture, system, version and installation form as shown in the figure below:
Choose the form of runfile (local), and the website will give us the command to install:
wget https://developer.download.nvidia.com/compute/cuda/11.7.0/local_installers/cuda_11.7.0_515.43.04_linux.run
sudo sh cuda_11.7.0_515.43.04_linux.run
Enter in the terminal in sequence.
First command:
Second command:
Attention! Since we have installed the driver before, don't install the driver again this time.
Enter accept
Press ENTER to tick off the Driver!
Then select Install
Finally, open the terminal and configure environment variables:
vim ~/.bashrc
Finally add:
export PATH=$PATH:/usr/local/cuda-11.7/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.7/lib64
Enter :wq
to exit.
Open a terminal and type:
source ~/.bashrc
Finish!
Finally, enter the terminal nvcc -V
to view the CUDA version:
install cudnn
Download the installation file
Open and log in to https://developer.nvidia.com/rdp/cudnn-download
and choose to download cuDNN v8.9.0 (for CUDA 11.x),
then choose Local Installer for Ubuntu22.04 x86_64 (Deb), and
the download will start. After downloading, it is recommended to move the deb file to the home directory.
Install
Open the Installation Guide above to view the installation method.
Among them we have installed the graphics driver and CUDA.
If the system has not installed the zlib package, you can sudo apt-get install zlib1g
install it first.
Installation steps:
1. Open the directory where the deb file is stored, right-click to open the terminal, and enter (the name of the deb file is the same as the one you downloaded):
sudo dpkg -i cudnn-local-repo-ubuntu2204-8.9.0.131_1.0-1_amd64.deb
2.Import the CUDA GPG key.
enter:
sudo cp /var/cudnn-local-repo-ubuntu2204-8.9.0.131/cudnn-local-2063C34E-keyring.gpg /usr/share/keyrings/
3. Refresh the library:
sudo apt-get update
4.Install the runtime library.
Note that the pairing of libcudnn8 and cuda version here is specified and can be
apt-cache policy libcudnn8
viewed through the command.
I should use libcudnn8=8.9.0.131-1+cuda11.8 here
enter:
sudo apt-get install libcudnn8=8.9.0.131-1+cuda11.8
5.Install the developer library.
sudo apt-get install libcudnn8-dev=8.9.0.131-1+cuda11.8
6.Install the code samples and the cuDNN library documentation.
sudo apt-get install libcudnn8-samples=8.9.0.131-1+cuda11.8
Verify that the installation was successful
cp -r /usr/src/cudnn_samples_v8/ $HOME
cd $HOME/cudnn_samples_v8/mnistCUDNN
make clean && make
./mnistCUDNN
Note: If the above make command prompts that FreeImage.h is missing, run:sudo apt-get install libfreeimage3 libfreeimage-dev
success: