@yangwenbo
2023-02-10T17:29:10.000000Z
字数 2520
阅读 215
清华大学-FIB实验室
可以去英伟达官网下载、安装最新的的版本,也可以根据自己需求去CUDA历史版本、CUDNN历史版本下载自己需要的版本。附送CUDA、CUDNN与tensorflow版本对应关系。
注意:请只用conda创建和管理环境,里面一切包用pip安装!!
#安装常用命令
(python-3.7) root@7a927d2dc743:~# pip install -i https://pypi.tuna.tsinghua.edu.cn/simple ipython pandas pillow matplotlib setproctitle networkx scikit-learn scipy tqdm GPUtil jupyterlab notebook h5py statsmodels
(python-3.7) root@7a927d2dc743:~# wget https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
(python-3.7) root@7a927d2dc743:~# ll -d cuda_10.2.89_440.33.01_linux.run
-rw-r--r-- 1 root root 2645419389 Nov 13 2019 cuda_10.2.89_440.33.01_linux.run
(python-3.7) root@7a927d2dc743:~# sh cuda_10.2.89_440.33.01_linux.run --silent --toolkit --samples --librarypath=/usr/local/cuda-10.2
(python-3.7) root@7a927d2dc743:~# ln -s /usr/local/cuda-10.2/bin/nvcc /usr/bin/nvcc-python-3.7
(python-3.7) root@7a927d2dc743:~# which nvcc-python-3.7
/usr/bin/nvcc-python-3.7
(python-3.7) root@7a927d2dc743:~# nvcc-python-3.7 -V
nvcc-python-3: 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
#添加环境变量到 ~/.bashrc 文件的末尾
(python-3.7) root@7a927d2dc743:~# vim ~/.bashrc
(python-3.7) root@7a927d2dc743:~# tail -3 ~/.bashrc
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
export PATH=$PATH:/usr/local/cuda/bin
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
#激活环境变量
(python-3.7) root@7a927d2dc743:~# source ~/.bashrc
#Result = PASS则安装成功
(python-3.7) root@7a927d2dc743:~# cd /usr/local/cuda-10.2/extras/demo_suite/
(python-3.7) root@7a927d2dc743:/usr/local/cuda/extras/demo_suite# ./deviceQuery
......
deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 11.6, CUDA Runtime Version = 10.2, NumDevs = 4, Device0 = NVIDIA GeForce RTX 2080 Ti, Device1 = NVIDIA GeForce RTX 2080 Ti, Device2 = NVIDIA GeForce RTX 2080 Ti, Device3 = NVIDIA GeForce RTX 2080 Ti
Result = PASS
(python-3.7) root@7a927d2dc743:~# ll -d cudnn-10.2-linux-x64-v7.6.5.32.tgz
-rw-r--r-- 1 root root 548210361 Mar 29 09:54 cudnn-10.2-linux-x64-v7.6.5.32.tgz
#解压缩
(python-3.7) root@7a927d2dc743:~# tar xf cudnn-10.2-linux-x64-v7.6.5.32.tgz
(python-3.7) root@7a927d2dc743:~# ll -d cuda
drwxr-xr-x 4 root root 70 Mar 29 09:55 cuda/
#把相应的文件,复制到指定目录即可
(python-3.7) root@7a927d2dc743:~# cp cuda/include/cudnn* /usr/local/cuda-10.2/include/
(python-3.7) root@7a927d2dc743:~# cp cuda/lib64/libcudnn* /usr/local/cuda-10.2/lib64/
#添加权限
(python-3.7) root@7a927d2dc743:~# chmod a+r /usr/local/cuda-10.2/include/cudnn* /usr/local/cuda-10.2/lib64/libcudnn*