安装最新版本的 CUDA 10.1
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# 卸载之前已经安装的cuda $ sudo apt-get remove nvidia-cuda-toolkit $ wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/cuda-ubuntu1804.pin $ sudo mv cuda-ubuntu1804.pin /etc/apt/preferences.d/cuda-repository-pin-600 $ wget http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb $ sudo dpkg -i cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00_1.0-1_amd64.deb $ sudo apt-key add /var/cuda-repo-10-1-local-10.1.243-418.87.00/7fa2af80.pub $ sudo apt-get update $ sudo apt-get -y install cuda # 部分驱动可能会更新,需要执行更新,否则可能依旧不正常 $ sudo apt-get dist-upgrade $ sudo apt-get autoremove # 可能需要删除一下XWindow的配置文件,否则驱动可能不能正常加载 $ sudo rm -rf ~/.Xauthority # 如果出现如下错误 # ubuntu 18.04 "nvidia-340 导致 /usr/lib/x86_64-linux-gnu/libGL.so.1 # 转移到 /usr/lib/x86_64-linux-gnu/libGL.so.1.distrib" # 参考 http://www.mobibrw.com/?p=21739 # 删除安装源,可以节约几个GB的磁盘,安装完成后这部分已经用不上了 $ sudo apt-get remove --purge cuda-repo-ubuntu1804-10-1-local-10.1.243-418.87.00 |
安装对应版本的cuDNN
:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
$ wget https://www.mobibrw.com/wp-content/uploads/2019/11/libcudnn7_7.6.5.32-1cuda10.1_amd64.deb_.zip $ wget https://www.mobibrw.com/wp-content/uploads/2019/11/libcudnn7-dev_7.6.5.32-1cuda10.1_amd64.deb_.zip $ wget https://www.mobibrw.com/wp-content/uploads/2019/11/libcudnn7-doc_7.6.5.32-1cuda10.1_amd64.deb_.zip # 解压缩 $ unzip libcudnn7_7.6.5.32-1cuda10.1_amd64.deb_.zip $ unzip libcudnn7-dev_7.6.5.32-1cuda10.1_amd64.deb_.zip $ unzip libcudnn7-doc_7.6.5.32-1cuda10.1_amd64.deb_.zip # 按照顺序安装 $ sudo dpkg -i libcudnn7_7.6.5.32-1+cuda10.1_amd64.deb $ sudo dpkg -i libcudnn7-dev_7.6.5.32-1+cuda10.1_amd64.deb $ sudo dpkg -i libcudnn7-doc_7.6.5.32-1+cuda10.1_amd64.deb |
检测是否成功安装:
1 2 3 4 5 6 7 |
$ cp -r /usr/src/cudnn_samples_v7/ ~/ $ cd ~/cudnn_samples_v7/mnistCUDNN $ make clean && make $ ./mnistCUDNN |
执行输出如下结果代表成功安装: