Install cuda11.7+cuDNN8.6 deb version on ubuntu2004

Install cuda11.7 + cuDNN8.6 deb version on ubuntu2004

  • 1. Graphics card driver installation
    • 1.1 Check the driver version
  • 2. Install cuda
    • 2.1 Inspection before installation
    • 2.2 Download CUDA11.7
    • 2.3 Installation
    • 2.4 Setting environment variables
    • 2.5 detection
  • 3.cuDNN installation
    • 3.1 Download cuDNN8.6
    • 3.2 Install cuDNN8.6 deb
    • 3.3 Test cuDNN
    • 3.4 Problem Description

The tutorial refers to the little monk sweeping the floor 1

1. Graphics card driver installation

In order to be stable and not toss, it is best to install the driver version recommended by the system.
Open Settings (software & amp;updates)
Select Additional Drivers

Just install the recommended driver.

1.1 View driver version

After the installation is complete enter

nvidia-smi

to test

2. Install cuda

2.1 Check before installation

1. Graphics card

lspci | grep -i nvidia

output

08:00.0 VGA compatible controller: NVIDIA Corporation Device 2484 (rev a1)
08:00.1 Audio device: NVIDIA Corporation Device 228b (rev a1)

2. System

uname -m & amp; & amp; cat /etc/*release

output

x86_64
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=20.04
DISTRIB_CODENAME=focal
DISTRIB_DESCRIPTION=”Ubuntu 20.04.5 LTS”
NAME=”Ubuntu”
VERSION=”20.04.5 LTS (Focal Fossa)”
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME=”Ubuntu 20.04.5 LTS”
VERSION_ID=”20.04″
HOME_URL=”https://www.ubuntu.com/”
SUPPORT_URL=”https://help.ubuntu.com/”
BUG_REPORT_URL=”https://bugs.launchpad.net/ubuntu/”
PRIVACY_POLICY_URL=”https://www.ubuntu.com/legal/terms-and-policies/privacy-policy”
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
3. gcc
gcc –version

output

gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
Copyright ? 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

2.2 Download CUDA11.7

https://developer.nvidia.com/cuda-downloads
Select “Archive of Previous CUDA Releases”
Find the cuda version cuda_11.7.1_515.65.01_linux.run corresponding to the graphics card driver “515.65”

As shown in the figure, the installation command has been given at the bottom. The network is not good, directly copy the address behind wget and download it with the downloader.

2.3 Installation

Finally, right click on the file directory to open the command line to install

wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_515.65.01_linux.run
sudo sh cuda_11.7.1_515.65.01_linux.run

Agree and continue, uncheck the driver (because the system has already installed it for us)

2.4 Setting environment variables

There will be a prompt after the installation is complete

===========
=Summary=
===========
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-11.7/

Please make sure that

  • PATH includes /usr/local/cuda-11.7/bin
  • LD_LIBRARY_PATH includes /usr/local/cuda-11.7/lib64, or, add /usr/local/cuda-11.7/lib64 to /etc/ld.so.conf and run ldconfig as root

To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-11.7/bin
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 515.00 is required for CUDA 11.7 functionality to work.
To install the driver using this installer, run the following command, replacing with the name of this run file:
sudo .run –silent –driver

Logfile is /var/log/cuda-installer.log

Prompts you to add environment variables

sudo gedit ~/.bashrc

or

vim ~/.bashrc

Add the last line:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda

After saving and closing, apply the changes

source ~/.bashrc
sudo ldconfig

2.5 Detection

nvcc -V

output:

nvcc: NVIDIA? Cuda compiler driver
Copyright ? 2005-2022 NVIDIA Corporation
Built on Wed_Jun__8_16:49:14_PDT_2022
Cuda compilation tools, release 11.7, V11.7.99
Build cuda_11.7.r11.7/compiler.31442593_0

To view your system GPU parameters, run deviceQuery:

/usr/local/cuda/extras/demo_suite/deviceQuery

output:

/usr/local/cuda/extras/demo_suite/deviceQuery Starting…

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

Detected 1 CUDA Capable device(s)

Device 0: “NVIDIA GeForce RTX 3070”
CUDA Driver Version / Runtime Version 11.7 / 11.7
CUDA Capability Major/Minor version number: 8.6
Total amount of global memory: 7981 MBytes (8368685056 bytes)
(46) Multiprocessors, (128) CUDA Cores/MP: 5888 CUDA Cores
GPU Max Clock Rate: 1830 MHz (1.83 GHz)
Memory Clock rate: 7001Mhz
Memory Bus Width: 256-bit
L2 Cache Size: 4194304 bytes
Maximum Texture Dimension Size (x,y,z) 1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
Maximum Layered 1D Texture Size, (num) layers 1D=(32768), 2048 layers
Maximum Layered 2D Texture Size, (num) layers 2D=(32768, 32768), 2048 layers
Total amount of constant memory: 65536 bytes
Total amount of shared memory per block: 49152 bytes
Total number of registers available per block: 65536
Warp size: 32
Maximum number of threads per multiprocessor: 1536
Maximum number of threads per block: 1024
Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
Max dimension size of a grid size (x,y,z): (2147483647, 65535, 65535)
Maximum memory pitch: 2147483647 bytes
Texture alignment: 512 bytes
Concurrent copy and kernel execution: Yes with 2 copy engine(s)
Run time limit on kernels: Yes
Integrated GPU sharing Host Memory: No
Support host page-locked memory mapping: Yes
Alignment requirement for Surfaces: Yes
Device has ECC support: Disabled
Device supports Unified Addressing (UVA): Yes
Device supports Compute Preemption: Yes
Supports Cooperative Kernel Launch: Yes
Supports MultiDevice Co-op Kernel Launch: Yes
Device PCI Domain ID / Bus ID / location ID: 0 / 8 / 0
Compute Mode:
< Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.7, CUDA Runtime Version = 11.7, NumDevs = 1, Device0 = NVIDIA GeForce RTX 3070
Result = PASS

3.cuDNN installation

I used deb installation, the address is as follows. Need to register and log in to NVIDIA.

https://developer.nvidia.com/rdp/cudnn-download

Also Archived cuDNN Releases (I don’t know what 11.x means, I didn’t find 11.7, so I installed 8.6, and finally it seems to be done)

3.1 Download cuDNN8.6

cudnn-local-repo-ubuntu2004-8.6.0.163_1.0-1_amd64.deb
Install according to the official documentation

https://docs.nvidia.com/deeplearning/cudnn/install-guide/index.html#installlinux-deb\

The documentation says that the cuDNN preconditions are
1. Install the graphics card driver
2. cuda
3. zlib

2.1.3. Installing Zlib
About this task
For Ubuntu users, to install the zlib package, run:
sudo apt-get install zlib1g

2.3.2. Debian Local Installation
Download the Debian local repository installation package. Before issuing the following commands, you must replace X.Y and 8.x.x.x with your specific CUDA and cuDNN versions.
Procedure
1. Navigate to your directory containing the cuDNN Debian local installer file.
2. Enable the local repository.
sudo dpkg -i cudnn-local-repo-${OS}-8.x.x.x_1.0-1_amd64.deb
Or
sudo dpkg -i cudnn-local-repo-${OS}-8.x.x.x_1.0-1_arm64.deb
3. Import the CUDA GPG key.
sudo cp /var/cudnn-local-repo-*/cudnn-local-*-keyring.gpg /usr/share/keyrings/
4. Refresh the repository metadata.
sudo apt-get update
5. Install the runtime library.
sudo apt-get install libcudnn8=8.x.x.x-1 + cudaX.Y
6. Install the developer library.
sudo apt-get install libcudnn8-dev=8.x.x.x-1 + cudaX.Y
7. Install the code samples and the cuDNN library documentation.
sudo apt-get install libcudnn8-samples=8.x.x.x-1 + cudaX.Y

3.2 Install cuDNN8.6 deb

Go to the download directory and open the terminal,
sudo dpkg -i cudnn-local-repo-ubuntu2004-8.6.0.163_1.0-1_amd64.deb
hint:

Selecting previously unselected package cudnn-local-repo-ubuntu2004-8.6.0.163.
(Reading database … 206235 files and directories currently installed.)
Preparing to unpack cudnn-local-repo-ubuntu2004-8.6.0.163_1.0-1_amd64.deb…
Unpacking cudnn-local-repo-ubuntu2004-8.6.0.163 (1.0-1)…
Setting up cudnn-local-repo-ubuntu2004-8.6.0.163 (1.0-1)…

The public cudnn-local-repo-ubuntu2004-8.6.0.163 GPG key does not appear to be installed.
To install the key, run this command:
sudo cp /var/cudnn-local-repo-ubuntu2004-8.6.0.163/cudnn-local-B0FE0A41-keyring.gpg /usr/share/keyrings/

Follow the official 3. Prompt input

sudo cp /var/cudnn-local-repo-ubuntu2004-8.6.0.163/cudnn-local-B0FE0A41-keyring.gpg /usr/share/keyrings/

According to the official 4.Refresh the repository metadata

sudo apt-get update

Open the path /var/cudnn-local-repo-ubuntu2004-8.6.0.163/

Enter according to the steps in 5.6.7.

sudo apt-get install libcudnn8=8.6.0.163-1+cuda11.8
sudo apt-get install libcudnn8-dev=8.6.0.163-1+cuda11.8
sudo apt-get install libcudnn8-samples=8.6.0.163-1+cuda11.8

Now it’s OKK

3.3 Testing cuDNN

2.4. Verifying the Install on Linux
To verify that cuDNN is installed and is running properly, compile the mnistCUDNN sample located in the /usr/src/cudnn_samples_v8 directory in the Debian file.
Procedure
Copy the cuDNN samples to a writable path.
cp -r /usr/src/cudnn_samples_v8/$HOME
Go to the writable path.
cd $HOME/cudnn_samples_v8/mnistCUDNN
Compile the mnistCUDNN sample.
make clean & amp; & amp; make
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!

3.4 Description of the problem

nvcc warning : The ‘compute_35’, ‘compute_37’, ‘sm_35’, and ‘sm_37’ architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
https://blog.csdn.net/qq_51182466/article/details/120183001
The reason is that the computing capabilities of compute capability 3.5 and 3.7 in CUDA are used in the Makefile. And I installed CUDA11.7, which may have abandoned these computing capabilities. Can be modified with cmake or GUI (I will not)
https://zhuanlan.zhihu.com/p/398023201
This tutorial teaches how to write, where SMS ? =35 37 50 52 60 is very similar
So search for SMS in the makefile of the HOME/cudnn_samples_v8/mnistCUDNN directory

#Gencode arguments
#Setting SMS inside samples_common.mk
include…/samples_common.mk

Open samples_common.mk in HOME/cudnn_samples_v8
the last line

SMS ?= 37 50 53 60 61 62 $(SMS_VOLTA) $(SMS_AMPERE)
Delete 37


  1. https://blog.csdn.net/kunhe0512/article/details/125061911
    #Nvidia driver installation