[关闭]
@yangwenbo 2023-02-10T17:29:10.000000Z 字数 2520 阅读 215

清华大学-FIB实验室

安装CUDA、CUDNN

可以去英伟达官网下载、安装最新的的版本,也可以根据自己需求去CUDA历史版本CUDNN历史版本下载自己需要的版本。附送CUDA、CUDNN与tensorflow版本对应关系

1、安装CUDA

1.1 安装常用软件命令

注意:请只用conda创建和管理环境,里面一切包用pip安装!!

  1. #安装常用命令
  2. (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

1.2 下载cuda

  1. (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
  2. (python-3.7) root@7a927d2dc743:~# ll -d cuda_10.2.89_440.33.01_linux.run
  3. -rw-r--r-- 1 root root 2645419389 Nov 13 2019 cuda_10.2.89_440.33.01_linux.run

1.3 安装cuda

  1. (python-3.7) root@7a927d2dc743:~# sh cuda_10.2.89_440.33.01_linux.run --silent --toolkit --samples --librarypath=/usr/local/cuda-10.2

1.4 检查安装的版本

  1. (python-3.7) root@7a927d2dc743:~# ln -s /usr/local/cuda-10.2/bin/nvcc /usr/bin/nvcc-python-3.7
  2. (python-3.7) root@7a927d2dc743:~# which nvcc-python-3.7
  3. /usr/bin/nvcc-python-3.7
  4. (python-3.7) root@7a927d2dc743:~# nvcc-python-3.7 -V
  5. nvcc-python-3: NVIDIA (R) Cuda compiler driver
  6. Copyright (c) 2005-2019 NVIDIA Corporation
  7. Built on Wed_Oct_23_19:24:38_PDT_2019
  8. Cuda compilation tools, release 10.2, V10.2.89

1.5 添加环境变量

  1. #添加环境变量到 ~/.bashrc 文件的末尾
  2. (python-3.7) root@7a927d2dc743:~# vim ~/.bashrc
  3. (python-3.7) root@7a927d2dc743:~# tail -3 ~/.bashrc
  4. export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64
  5. export PATH=$PATH:/usr/local/cuda/bin
  6. export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
  7. #激活环境变量
  8. (python-3.7) root@7a927d2dc743:~# source ~/.bashrc

1.6 测试 CUDA Toolkit 以验证是否安装成功

  1. #Result = PASS则安装成功
  2. (python-3.7) root@7a927d2dc743:~# cd /usr/local/cuda-10.2/extras/demo_suite/
  3. (python-3.7) root@7a927d2dc743:/usr/local/cuda/extras/demo_suite# ./deviceQuery
  4. ......
  5. 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
  6. Result = PASS

2、安装CUDNN

2.1 下载cudnn

  1. (python-3.7) root@7a927d2dc743:~# ll -d cudnn-10.2-linux-x64-v7.6.5.32.tgz
  2. -rw-r--r-- 1 root root 548210361 Mar 29 09:54 cudnn-10.2-linux-x64-v7.6.5.32.tgz
  3. #解压缩
  4. (python-3.7) root@7a927d2dc743:~# tar xf cudnn-10.2-linux-x64-v7.6.5.32.tgz
  5. (python-3.7) root@7a927d2dc743:~# ll -d cuda
  6. drwxr-xr-x 4 root root 70 Mar 29 09:55 cuda/

2.2 安装cudnn

  1. #把相应的文件,复制到指定目录即可
  2. (python-3.7) root@7a927d2dc743:~# cp cuda/include/cudnn* /usr/local/cuda-10.2/include/
  3. (python-3.7) root@7a927d2dc743:~# cp cuda/lib64/libcudnn* /usr/local/cuda-10.2/lib64/
  4. #添加权限
  5. (python-3.7) root@7a927d2dc743:~# chmod a+r /usr/local/cuda-10.2/include/cudnn* /usr/local/cuda-10.2/lib64/libcudnn*
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注