ubuntu20.04+cuda+cudnn installation

Foreword:

CUDA and cuDNN installation (linux) Install graphics driver and CUDA program under Linux

System parameters:

System: ubuntu20.04.2

Graphics card: GeForce GTX 1050

Version to be installed: CUDA 11.4

1. Install the graphics card driver

  (1)  Detect the model of your NVIDIA graphics card and the recommended driver

ubuntu-drivers devices

  (2) Choose to install all recommended drivers

sudo ubuntu-drivers autoinstall

    (3) nvidia-smi checks whether the driver installation is successful

The results show that:

NVIDIA-SMI 470.74      Driver Version: 470.74      CUDA Version: 11.4        

Second, install the CUDA program

   (1) Download cuda:  

Enter NVIDIA to download the installation package CUDA Toolkit 11.7 Downloads | NVIDIA Developer

Select the corresponding version, and enter the relevant commands in the terminal (note: enter your own installation version)

wget http://developer.download.nvidia.com/compute/cuda/11.0.2/local_installers/cuda_11.0.2_450.51.05_linux.run 

    (2) cuda installation:

sudo sh cuda_11.0.2_450.51.05_linux.run

   (3) cuda environment variable configuration:
              .1. Install vim package

sudo apt install vim         # version 2:8.1.2269-1ubuntu5.4, or
sudo apt install vim-tiny    # version 2:8.1.2269-1ubuntu5.4
sudo apt install neovim      # version 0.4.3-3
sudo apt install vim-athena  # version 2:8.1.2269-1ubuntu5.4
sudo apt install vim-gtk3    # version 2:8.1.2269-1ubuntu5.4
sudo apt install vim-nox     # version 2:8.1.2269-1ubuntu5.4

             .2. Setting environment variables    gedit ~/.bashrc 推荐用这个,打开是文件好操作

vim ~/.bashrc 

Open the file and enter the following: (note:    i插入    :wq 退出 )

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

Finally, enter the following to update the environment variables

source ~/.bashrc

(4) Check whether the installation is successful

nvcc -V

3. Install the cudnn program

(1) cudnn download

        cuDNN is a library for GPU-accelerated computing of deep neural networks. First go to the official website  cuDNN Archive | NVIDIA Developer (2) Installation

    解压缩->在压缩后的cuda文件夹,打开终端

#Note, the unzipped folder will copy the corresponding file to cuda in /usr/local 

sudo cp cuda/include/cudnn.h /usr/local/cuda-11.0/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-11.0/lib64/
sudo chmod a+r /usr/local/cuda-11.0/include/cudnn.h
sudo chmod a+r /usr/local/cuda-11.0/lib64/libcudnn*

Guess you like

Origin blog.csdn.net/m0_48919875/article/details/125161788