Catalog title
1. Download the corresponding CUDA
The premise that the nvidia driver has been installed, check Tutorial 1:
Check the correspondence between cuda and driver (as shown in the figure): The official cuda and driver correspond to
the driver I installed is 440.100, so I should choose CUDA10.2.89. Go to CUDA download , pull to the bottom of the page and select download now, you can see the old cuda version (as shown in the figure).
2. Install CUDA
Select CUDA Toolkit 10.2 in the quick start guide , see the download page as follows, enter the prompt command in the terminal.
Note that if installation failed, you need to modify the run file permissions first:
sudo chmod a+x cuda_10.2.89_440.33.01_linux.run
sudo sh cuda_10.2.89_440.33.01_linux.run
Then start to enter the installation, enter accept after a lot of text to accept the agreement.
Prompt that incomplete installation does not matter here.
Configure cuda environment variables:
sudo su //切换为root超级用户的命令
sudo gedit ~/.bashrc //打开.bashrc文件
//在~/.bashrc的最后添加:
export PATH=/usr/local/cuda-10.2/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
Be sure to update after adding: source ~/.bashrc
3. Test whether CUDA is installed successfully
nvcc --version
After success, it is displayed to
execute a program in the samples to check:
cd /home/hy/NVIDIA_CUDA-10.2_Samples/1_Utilities/deviceQuery //输入自己的samples文件夹路径
sudo make
./deviceQuery
The final result result=PASS should be considered successful.
4. Install cudnn
First go to the official website to download cuDNN https://developer.nvidia.com/cudnn , you need to register as a developer to download. Select the cudnn corresponding to the cuda version. Mine is cuda10.2, so choose cudnn8, click cudnn library for linux (x86), and download the cudnn-xxxx.tgz file.
unzip files:
tar xvzf cudnn-10.2-linux-x64-v8.0.1.13.tgz
After the decompression is complete, you get a cuda folder, which has two folders including include and lib64. Switch to the cuda/include path and perform the following operations:
sudo cp cudnn.h /usr/local/cuda/include/
sudo chmod a+r /usr/local/cuda/include/cudnn.h
Switch to cuda/lib64:
sudo cp lib* /usr/local/cuda/lib64/
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
5. Check the cudnn version
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
#define CUDNN_MAJOR 8
#define CUDNN_MINOR 0
#define CUDNN_PATCHLEVEL 1
–
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
#include “driver_types.h”