cuda安装:
cuda 所有版本下载页面
https://developer.nvidia.com/cuda-toolkit-archive
下了一个9.0的run文件
把run文件放在home下右击更改一下权限(在permission里边勾上最后的点)
配置一下环境变量
sudo gedit ~/.bashrc(我自己用的是gedit)
打开之后添加两行
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
在run文件夹路径下执行
sudo sh cuda_8.0.61_375.26_linux.run
点击enter键直到百分之百
接下来
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 361.62?
(y)es/(n)o/(q)uit: n
Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y
Enter Toolkit Location
[ default is /usr/local/cuda-8.0 ]: 回车
Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y
Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y
Enter CUDA Samples Location
[ default is /root ]:回车
看见类似与下方文字就证明装好了
To uninstall the CUDA Toolkit, run the uninstall script in /usr/local/cuda-8.0/bin
Please see CUDA_Installation_Guide_Linux.pdf in /usr/local/cuda-8.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 361.00 is required for CUDA 8.0 functionality to work.
To install the driver using this installer, run the following command, replacing with the name of this run filesudo.run -silent -driver
再配置一下
sudo gedit ~/.bashrc
末尾添加
export PATH=/usr/local/cuda-9.1/bin:$PATH(注意你的cuda版本号要写对)
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
更新一下环境变量
命令行输入source ~/.bashrc
然后设置环境变量和动态链接库,在命令行输入:sudo gedit /etc/profile
在打开的文件末尾加入:
export PATH=/usr/local/cuda/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-9.1/lib64$LD_LIBRARY_PATH(同样注意版本号)
创建链接文件:sudo gedit /etc/ld.so.conf.d/cuda.conf
添加/usr/local/cuda/lib64
执行:sudo ldconfig
验证安装:
-
cd /usr/local/cuda-9.1/samples/1_Utilities/deviceQuery(注意版本号)
-
sudo make
-
./deviceQuery
参考博客:https://blog.csdn.net/qq_35379989/article/details/80147630
cudnn安装:
按需求下载cudnn的安装文件:https://developer.nvidia.com/rdp/cudnn-archive
解压下载的文件,可以看到一个名为cuda的文件夹,在当前目录打开终端,执行如下命令:
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*
查看cudnn版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2不报错有正确输出就可
参考博客:https://blog.csdn.net/wanzhen4330/article/details/81699769