目录
一、安装CUDA
1.博主这里选择9.0版本,CUDA历代版本下载的网址为:https://developer.nvidia.com/cuda-toolkit-archive
2.如下选择
3.执行指令:
-
sudo dpkg -i cuda-repo-ubuntu1604-9-0-local_9.0.176-1_amd64.deb
-
sudo apt-key add /var/cuda-repo-9-0-local/7fa2af80.pub
-
sudo apt-get update
-
sudo apt-get install cuda
二、下载cuDNN
1.网址:https://developer.nvidia.com/rdp/cudnn-archive
2.选择7.4.1的cuDNN Library for Linux下载
3.解压:
sudo tar -zxvf cudnn-9.0-linux-x64-v7.4.1.5.tgz
4.复制cuDNN的文件到已经安装好的目录中
-
sudo cp cuda/include/cudnn.h /usr/local/cuda/include
-
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64
-
sudo chmod a+r /usr/local/cuda/include/cudnn.h
-
sudo chmod a+r /usr/local/cuda/lib64/libcudnn*
三、设置环境变量
1.编辑环境变量文件.bashrc
sudo gedit ~/.bashrc
2.最下面添加这几句话
-
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
-
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
-
export CUDA_HOME=/usr/local/cuda
四、查看安装是否成功
1.重启电脑/注销用户
2.打开终端,输入
nvcc -V
应该显示如下类似字样
-
nvcc: NVIDIA (R) Cuda compiler driver
-
Copyright (c) 2005-2017 NVIDIA Corporation
-
Built on Fri_Sep__1_21:08:03_CDT_2017
-
Cuda compilation tools, release 9.0, V9.0.176
3.输入
nvidia-smi
应该显示如下类似字样
-
Wed May 15 19:50:57 2019
-
+-----------------------------------------------------------------------------+
-
| NVIDIA-SMI 384.130 Driver Version: 384.130 |
-
|-------------------------------+----------------------+----------------------+
-
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
-
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
-
|===============================+======================+======================|
-
| 0 GeForce GTX 108... Off | 00000000:01:00.0 On | N/A |
-
| 20% 39C P8 16W / 250W | 387MiB / 11169MiB | 1% Default |
-
+-------------------------------+----------------------+----------------------+
-
-
+-----------------------------------------------------------------------------+
-
| Processes: GPU Memory |
-
| GPU PID Type Process name Usage |
-
|=============================================================================|
-
| 0 1105 G /usr/lib/xorg/Xorg 219MiB |
-
| 0 2062 G compiz 41MiB |
-
| 0 2464 G /proc/self/exe 99MiB |
-
| 0 3256 G ...passed-by-fd --v8-snapshot-passed-by-fd 24MiB |
-
+-----------------------------------------------------------------------------+
说明CUDA和cuDNN安装成功~(没有很可能是环境变量设置出了问题)
文章来源: nickhuang1996.blog.csdn.net,作者:悲恋花丶无心之人,版权归原作者所有,如需转载,请联系作者。
原文链接:nickhuang1996.blog.csdn.net/article/details/90243205