最近重装了几次,干脆写个笔记;另外我习惯用oh-my-zsh
所以顺带写了安装这个后的配置方法。
安装显卡驱动
检查一下你有没有驱动
nvidia-smi
如果没有,那就去安装一下。
显卡安装教程
安装cuda
我的版本是cuda_9.0.176_384.81_linux.run
切换到该文件目录下
# 先更改权限以免报错
chmod a+x cuda_9.0.176_384.81_linux.run
# 再进行安装
sudo bash ./cuda_9.0.176_384.81_linux.run
## 下面是输出是我设定的安装结果。
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 384.81?
(y)es/(n)o/(q)uit: no
Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: yes
Enter Toolkit Location
[ default is /usr/local/cuda-9.0 ]:
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: yes
Install the CUDA 9.0 Samples?
(y)es/(n)o/(q)uit: no
# 输出
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-9.0/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 384.00 is required for CUDA 9.0 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 /tmp/cuda_install_12169.log
这就代表安装完毕了。
配置CUDA
这里要注意分装了oh-my-zsh
和没有安装oh-my-zsh
的同学,我是安装了
# 没有安装oh-my-zsh的
sudo gedit ~/.bashrc
# 安装了oh-my-zsh的同学
sudo gedit ~/.zshrc
## 文件最后加上
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
然后我们再激活一下配置文件source ~/.bashrc
同样,如果你安装了oh-my-zsh
就需要source ~/.zshrc
检查一下
╭─zy@zy ~
╰─$ cat /proc/driver/nvidia/version
# 输出显示版本是435.21,GCC版本是5.4.0
NVRM version: NVIDIA UNIX x86_64 Kernel Module 435.21 Sun Aug 25 08:17:57 CDT 2019
GCC version: gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)
## 查看一下cuda版本
╭─zy@zy ~
╰─$ nvcc -V
# 这代表你装上了,版本是9.0
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
安装cudnn
下载就不说了,我下载的是cudnn-9.0-linux-x64-v7.0.5.tgz
,理论上7.0版本都是可以的。
# 1. 解压
tar -zxvf cudnn-9.0-linux-x64-v7.6.1.34.tgz
## 会有一些输出
# 2. 拷贝,注意星号别丢了
sudo cp cuda/include/cudnn.h /usr/local/cuda/include/
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64/
# 3. 软链接,可用可不用
cd /usr/local/cuda/lib64
sudo chmod +r libcudnn.so.7.6.1
sudo ln -sf libcudnn.so.7.6.1 libcudnn.so.7
sudo ln -sf libcudnn.so.7 libcudnn.so
sudo ldconfig
## 有空可以ls检查一下对不对咯,我没弄
来源:https://blog.csdn.net/xinjieyuan/article/details/100667803