无sudo权限,参考https://blog.csdn.net/weixin_41278720/article/details/81255265 CUDA Toolkit 9.0和cudnn 7
CUDA Toolkit 9.0.png
参考https://www.jianshu.com/p/9c98d51e4de3
1.下载好文件,进入文件路径
2.运行安装命令
sudo sh cuda_9.0.176_384.81_linux.run
3.安装过程中的一些选择
Do you accept the previously read EULA?
accept/decline/quit: accept
Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 396.37?
(y)es/(n)o/(q)uit: n
Install the CUDA 9.0 Toolkit?
(y)es/(n)o/(q)uit: y
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: y
Install the CUDA 9.0 Samples?
(y)es/(n)o/(q)uit: y
4.在/usr/local可以看到cuda cuda-8.0 cuda-9.0 cuda-9.2 5.在~/.bashrc中添加/修改环境变量:
export PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda/lib64
在终端运行source ~/.bashrc使之生效
6.nvcc --version查看当前使用的cuda版本 将其切换到cuda-9.0
sudo rm -rf /usr/local/cuda #删除之前创建的软链接
sudo ln -s /usr/local/cuda-9.0 /usr/local/cuda #创建新的软链接
nvcc --version
测试
cd /usr/local/cuda-9.2/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
cd ../bandwidthTest
sudo make
./bandwidthTest
如果这两个测试结果都是Result = PASS,则说明安装成功了
根据cuda-cudnn找对应版本
https://developer.nvidia.com/rdp/cudnn-archive
cudnn-archive.png
1.进入下载好的文件目录,用命令解压:
cp cudnn-9.0-linux-x64-v7.solitairetheme8 cudnn-9.0-linux-x64-v7.0.5.tgz
tar -xvzf cudnn-9.2-linux-x64-v7.4.2.24.tgz
在解压后,得到的cuda目录下执行复制lib64和include文件夹到usr/local/cuda-9.0:
sudo cp include/cudnn.h /usr/local/cuda/include/
sudo cp lib64/lib* /usr/local/cuda/lib64/
之后执行
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
查看cudnn版本为7.0.5:
#define CUDNN_MAJOR 7
#define CUDNN_MINOR 0
#define CUDNN_PATCHLEVEL 5
--
#define CUDNN_VERSION (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)
cat /usr/local/cuda/version.txt
请安装相应的TensorFlow或者CUDA版本
pip install tensorflow-gpu==版本号
4、如果匹配,仍然报错 那是因为你的cuda环境变量配置有误,请执行:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/【CUDA版本】/lib64
例如
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-9.0/lib64