Article directory
Preparation
Note: The local system is Ubuntu20.04
1. Install the graphics card driver
Open 'Software and Updates, click Additional Drivers to install the graphics card driver.
2. gcc installation
If the system is Ubuntu22.04, it needs to be installed.
Enter the command in the terminal to see if there is gcc.
gcc --version
3. gcc installation
The native version of ubuntu20.04 gcc is 9.4.0
to install gcc-7, command:
sudo apt-get install gcc-7 g++-7
After installing gcc-7, there are two versions of gcc in the system, so to set the default gcc, the command is as follows:
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-7 9
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 1
This command can set the priority of each version of gcc through update-alternatives. The highest priority is the system default version. You can use the following command to display its priority:
sudo update-alternatives --display gcc
CUDA installation
Install CUDA 11.7, select runfile(local), and use the generated instructions to download and install.
Select the corresponding version, and then you can install the command below:
woet httos://developer.donnload,nvidia.com/compute/cuda/11,7.0/local installers/cuda 11,7.0 515,43.04 linux.rurs
sudo sh cuda 11.7.0 51543.04 linux.run
Execute the above generation command in the terminal, as shown in the figure below.
If step 1 prompts Existing package manager installation of the driver found. It is strongly recommended that you remove this before continuing., select continue , remove the driver item in the next step , and then select install :
After the installation is complete, the display is as follows:
in ~/ Add the following environment variables to the .bashrc file:
export PATH=/usr/local/cuda-11.7/bin${
PATH:+:${
PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
If other versions have been installed before, delete the previous environment variables and import the environment variables of this installation.
Note: For vim operation, enter i to insert and then esc to enter: wq to save
View vim instructions and click: link .
Use the following command to update the system environment variables
source ~/.bashrc
sudo ldconfig
At this point, the cuda installation is complete, enter the nvcc -V command to view the cuda information
nvcc -V
cudnn installation
Download link: https://developer.nvidia.com/rdp/cudnn-download
Note: The red box version in the picture
Change the permissions of the include and lib64 folders under the usr/local/cuda/ folder.
Commonly used commands to modify permissions
sudo chmod 600 ××× (只有所有者有读和写的权限)
sudo chmod 644 ××× (所有者有读和写的权限,组用户只有读的权限)
sudo chmod 700 ××× (只有所有者有读和写以及执行的权限)
sudo chmod 666 ××× (每个人都有读和写的权限)
sudo chmod 777 ××× (每个人都有读和写以及执行的权限)
Execute the command to modify the permissions of the folder:
cd /usr/local/cuda
sudo chmod 666 include
sudo chmod 666 lib64
Then extract the cudnn-linux-x86_64-8.6.0.163_cuda11-archive.tar.xz file. After waiting for the decompression to complete, right-click in the download folder to open the terminal. Execute the following command:
sudo cp cudnn-*-archive/include/cudnn*.h /usr/local/cuda/include
sudo cp cudnn-*-archive/lib/libcudnn* /usr/local/cuda/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn*.h /usr/local/cuda/lib64/libcudnn*
See NVIDIA official installation guide 1.3.1 ( Installation Guide : Step-by-step instructions for installation and upgrade)
to verify whether the installation is successful, execute the command:
sudo cat /usr/local/cuda/include/cudnn_version.h | grep CUDNN_MAJOR -A 2
At this point cudnn is also installed.