“Installing cuda and cudnn under heqingchun-ubuntu system”

Installing cuda and cudnn under ubuntu system

1. Install dependencies

1.Update

sudo apt update
sudo apt upgrade -y

2. Basic tools

sudo apt install -y build-essential

2. Install CUDA

1. File download

URL

https://developer.nvidia.com/cuda-toolkit-archive

Click in turn

(1)”CUDA Toolkit 11.6.2″
(2)”Linux”
(3)”x86_64″
(4)”Ubuntu”
(5)“20.04”
(6)”runfile(local)”

Under “Installation Instructions:” are the download and installation instructions
Download instructions (The file needs to be downloaded to an English path), such as:

cd /home/heqingchun/soft/nvidia
wget https://developer.download.nvidia.com/compute/cuda/11.6.2/local_installers/cuda_11.6.2_510.47.03_linux.run

Download the “cuda_11.6.2_510.47.03_linux.run” file in the “/home/heqingchun/soft/nvidia” path
The following are the instructions used during installation

sudo sh cuda_11.6.2_510.47.03_linux.run

2.cuda installation

(1) Grant executable permissions
chmod 755 cuda_11.6.2_510.47.03_linux.run
(2) Run the installation
sudo sh cuda_11.6.2_510.47.03_linux.run

A dialog box will pop up during this period. You need to manually enter “accept” and press Enter. Then uncheck “Driver” in the dialog box that pops up later.

CUDA Installer │
│ - [ ] Driver │
│ [ ] 510.47.03 │
│ + [X] CUDA Toolkit 11.6 │
│ [X] CUDA Samples 11.6 │
│ [X] CUDA Demo Suite 11.6 │
│ [X] CUDA Documentation 11.6 │
│ Options │
│Install

Select “install” down and wait for the installation to complete.
Installation completion information:

===========
= Summary =
===========

Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-11.6/

Please make sure that
 - PATH includes /usr/local/cuda-11.6/bin
 - LD_LIBRARY_PATH includes /usr/local/cuda-11.6/lib64, or, add /usr/local/cuda-11.6/lib64 to /etc/ld.so.conf and run ldconfig as root

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

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

(3) Configure environment variables
str='export PATH=/usr/local/cuda-11.6/bin:"$"PATH' & amp; & amp; \
sudo sh -c "echo $str >> /etc/profile" & amp; & amp; \
source /etc/profile & amp; & amp; \
str='export LD_LIBRARY_PATH=/usr/local/cuda-11.6/lib64:"$"LD_LIBRARY_PATH' & amp; & amp; \
sudo sh -c "echo $str >> /etc/profile" & amp; & amp; \
source /etc/profile
(4) Restart the computer

3. Verify installation

(1) Version information
nvcc -V

Displayed as follows:

nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2022 NVIDIA Corporation
Built on Tue_Mar__8_18:18:20_PST_2022
Cuda compilation tools, release 11.6, V11.6.124
Build cuda_11.6.r11.6/compiler.31057947_0
(2)Library information
cat /usr/local/cuda/version.json

Displayed as follows:

{
   "cuda" : {
      "name" : "CUDA SDK",
      "version" : "11.6.20220318"
   },
   "cuda_cccl" : {
      "name" : "CUDA C++ Core Compute Libraries",
      "version" : "11.6.55"
   },
   "cuda_cudart" : {
      "name" : "CUDA Runtime (cudart)",
      "version" : "11.6.55"
   },
   "cuda_cuobjdump" : {
      "name" : "cuobjdump",
      "version" : "11.6.124"
   },
   "cuda_cupti" : {
      "name" : "CUPTI",
      "version" : "11.6.124"
   },
   "cuda_cuxxfilt" : {
      "name" : "CUDA cu + + filt",
      "version" : "11.6.124"
   },
   "cuda_demo_suite" : {
      "name" : "CUDA Demo Suite",
      "version" : "11.6.55"
   },
   "cuda_gdb" : {
      "name" : "CUDA GDB",
      "version" : "11.6.124"
   },
   "cuda_memcheck" : {
      "name" : "CUDA Memcheck",
      "version" : "11.6.124"
   },
   "cuda_nsight" : {
      "name" : "Nsight Eclipse Plugins",
      "version" : "11.6.124"
   },
   "cuda_nvcc" : {
      "name" : "CUDA NVCC",
      "version" : "11.6.124"
   },
   "cuda_nvdisasm" : {
      "name" : "CUDA nvdisasm",
      "version" : "11.6.124"
   },
   "cuda_nvml_dev" : {
      "name" : "CUDA NVML Headers",
      "version" : "11.6.55"
   },
   "cuda_nvprof" : {
      "name" : "CUDA nvprof",
      "version" : "11.6.124"
   },
   "cuda_nvprune" : {
      "name" : "CUDA nvprune",
      "version" : "11.6.124"
   },
   "cuda_nvrtc" : {
      "name" : "CUDA NVRTC",
      "version" : "11.6.124"
   },
   "cuda_nvtx" : {
      "name" : "CUDA NVTX",
      "version" : "11.6.124"
   },
   "cuda_nvvp" : {
      "name" : "CUDA NVVP",
      "version" : "11.6.124"
   },
   "cuda_samples" : {
      "name" : "CUDA Samples",
      "version" : "11.6.101"
   },
   "cuda_sanitizer_api" : {
      "name" : "CUDA Compute Sanitizer API",
      "version" : "11.6.124"
   },
   "libcublas" : {
      "name" : "CUDA cuBLAS",
      "version" : "11.9.2.110"
   },
   "libcufft" : {
      "name" : "CUDA cuFFT",
      "version" : "10.7.2.124"
   },
   "libcurand" : {
      "name" : "CUDA cuRAND",
      "version" : "10.2.9.124"
   },
   "libcusolver" : {
      "name" : "CUDA cuSOLVER",
      "version" : "11.3.4.124"
   },
   "libcusparse" : {
      "name" : "CUDA cuSPARSE",
      "version" : "11.7.2.124"
   },
   "libnpp" : {
      "name" : "CUDA NPP",
      "version" : "11.6.3.124"
   },
   "libnvjpeg" : {
      "name" : "CUDA nvJPEG",
      "version" : "11.6.2.124"
   },
   "nsight_compute" : {
      "name" : "Nsight Compute",
      "version" : "2022.1.1.2"
   },
   "nsight_systems" : {
      "name" : "Nsight Systems",
      "version" : "2021.5.2.53"
   },
   "nvidia_driver" : {
      "name" : "NVIDIA Linux Driver",
      "version" : "510.47.03"
   }
}
(3)Computing ability
cd /usr/local/cuda/extras/demo_suite
./deviceQuery

show:

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.6, CUDA Runtime Version = 11.6, NumDevs = 1, Device0 = NVIDIA GeForce RTX 3050 Laptop GPU
Result = PASS

CUDA is installed

3. Install cuDNN

1. File download

URL

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

Click in turn

(1)“Download cuDNN v8.4.0 (April 1st, 2022), for CUDA 11.x”

(2)”Local Installer for Linux x86_64 (Tar)”

Note: You need to log in, you can download after successful login
Download the “cudnn-linux-x86_64-8.4.0.27_cuda11.6-archive.tar.xz” file and put it in the “/home/heqingchun/soft/nvidia” directory

2.cuDNN installation

Enter the directory where the file is located, decompress the file, enter the folder after decompression, and copy the file

cd /home/heqingchun/soft/nvidia
tar -xvf cudnn-linux-x86_64-8.4.0.27_cuda11.6-archive.tar.xz
cd cudnn-linux-x86_64-8.4.0.27_cuda11.6-archive
sudo cp include/* /usr/local/cuda-11.6/include & amp; & amp; \
sudo cp -P lib/* /usr/local/cuda-11.6/lib64 & amp; & amp; \
sudo chmod a + r /usr/local/cuda-11.6/include/cudnn*.h /usr/local/cuda-11.6/lib64/libcudnn*

Restart the computer

3. Verify installation

cat /usr/local/cuda/include/cudnn_version.h

Displayed as follows:

/**
 * \file: The master cuDNN version file.
 */

#ifndef CUDNN_VERSION_H_
#define CUDNN_VERSION_H_

#define CUDNN_MAJOR 8
#define CUDNN_MINOR 4
#define CUDNN_PATCHLEVEL 0

#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)

#endif /* CUDNN_VERSION_H */

cuDNN is installed
Installation of cuda and cudnn under ubuntu system-completed