先安装 nvidia
驱动,请参考前面文章 https://blog.csdn.net/wohu1104/article/details/107032493
在官网 https://developer.nvidia.com/cuda-toolkit-archive如下截图, 选择自己系统对应的 CUDA
版本,
然后点击进去,进入安装方式页面,如下图
然后在命令行中执行以下语句:
wget http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.runsudo
sh cuda_10.2.89_440.33.01_linux.run
安装过程如下:
这里注意去勾选 NVIDIA Driver
因为前面已经安装,所以此处不需要再安装。
wohu@ubuntu1804:~/CUDA10-linux$ sudo ./cuda_10.2.89_440.33.01_linux.run
===========
= Summary =
===========
Driver: Not Selected
Toolkit: Installed in /usr/local/cuda-10.2/
Samples: Installed in /home/wohu/, but missing recommended libraries
Please make sure that
- PATH includes /usr/local/cuda-10.2/bin
- LD_LIBRARY_PATH includes /usr/local/cuda-10.2/lib64, or, add /usr/local/cuda-10.2/lib64 to /etc/ld.so.conf and run ldconfig as root
To uninstall the CUDA Toolkit, run cuda-uninstaller in /usr/local/cuda-10.2/bin
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-10.2/doc/pdf for detailed information on setting up CUDA.
***WARNING: Incomplete installation! This installation did not install the CUDA Driver. A driver of version at least 440.00 is required for CUDA 10.2 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
可以看到 /usr/local/
目录下已经有 cuda -> /usr/local/cuda-10.2//
软链接。
wohu@ubuntu1804:~/CUDA10-linux$ ll /usr/local/
total 48
drwxr-xr-x 12 root root 4096 6月 30 09:25 ./
drwxr-xr-x 11 root root 4096 2月 4 02:25 ../
drwxr-xr-x 2 root root 4096 2月 4 02:22 bin/
lrwxrwxrwx 1 root root 21 6月 30 09:25 cuda -> /usr/local/cuda-10.2//
drwxr-xr-x 18 root root 4096 6月 30 09:25 cuda-10.2/
drwxr-xr-x 2 root root 4096 2月 4 02:22 etc/
drwxr-xr-x 2 root root 4096 2月 4 02:22 games/
drwxr-xr-x 2 root root 4096 2月 4 02:22 include/
drwxr-xr-x 4 root root 4096 6月 29 18:35 lib/
lrwxrwxrwx 1 root root 9 6月 16 16:24 man -> share/man/
drwxr-xr-x 2 root root 4096 2月 4 02:22 sbin/
drwxr-xr-x 6 root root 4096 2月 4 02:25 share/
drwxr-xr-x 2 root root 4096 2月 4 02:22 src/
drwxr-xr-x 6 root root 4096 6月 19 18:49 sunlogin/
wohu@ubuntu1804:~/CUDA10-linux$
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 410.48?
(y)es/(n)o/(q)uit: n
Install the CUDA 10.0 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
[ default is /usr/local/cuda-10.0 ]: 回车
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y
Install the CUDA 10.0 Samples?
(y)es/(n)o/(q)uit: y
Enter CUDA Samples Location
[ default is /home/linkdome ]: 回车
打开 ~/.bashrc
sudo vi ~/.bashrc
在文件最后添加以下环境变量到 ~/.bashrc
并保存退出。
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
使其生效
sudo source ~/.bashrc
最后输入命令 nvcc -V
有如下输出,说明已安装成功。
wohu@ubuntu1804:/$ nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89
wohu@ubuntu1804:/$
官网地址 https://developer.nvidia.com/rdp/form/cudnn-download-survey 注册账号,并下载对应版本的 cuDNN
版本。
对压缩包进行解压:
tar -xvf cudnn-10.2-linux-x64-v7.6.5.32.tgz
解压过程如下:
wohu@ubuntu1804:~/CUDA10-linux$ tar -xvf cudnn-10.2-linux-x64-v7.6.5.32.tgz
cuda/include/cudnn.h
cuda/NVIDIA_SLA_cuDNN_Support.txt
cuda/lib64/libcudnn.so
cuda/lib64/libcudnn.so.7
cuda/lib64/libcudnn.so.7.6.5
cuda/lib64/libcudnn_static.a
wohu@ubuntu1804:~/CUDA10-linux$
执行以下命令:
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
输入以下命令,
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2