在Ubuntu 16.04 使用命令行安装Nvidia CUDA-9.0以及cudnn7

本资料在ubuntu16.04上安装cuda-9.0,使用命令行,无需上nvidia官网下载包。

  • OS: Ubuntu 16.04 x86_64
  • (可选择项) 卸载旧版CUDA,类似于以下操作:
sudo apt-get purge cuda
sudo apt-get purge libcudnn6
sudo apt-get purge libcudnn6-dev
  • 安装CUDA Toolkit 9.0 和cuDNN 7.0 :
wget http://developer.download.nvidia.com/compute/cuda/repos/ubuntu1604/x86_64/cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl2_2.1.4-1+cuda9.0_amd64.deb
wget http://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1604/x86_64/libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
sudo dpkg -i cuda-repo-ubuntu1604_9.0.176-1_amd64.deb
sudo dpkg -i libcudnn7_7.0.5.15-1+cuda9.0_amd64.deb
sudo dpkg -i libcudnn7-dev_7.0.5.15-1+cuda9.0_amd64.deb
sudo dpkg -i libnccl2_2.1.4-1+cuda9.0_amd64.deb
sudo dpkg -i libnccl-dev_2.1.4-1+cuda9.0_amd64.deb
sudo apt-get update
sudo apt-get install cuda=9.0.176-1
sudo apt-get install libcudnn7-dev
sudo apt-get install libnccl-dev
  • 重启,若机器无法重启,则参考资料2
  • nvidia-smi查看显卡信息
  • 设置环境 添加 PATH and LD_LIBRARY_PATH 到 .bashrc 的最后:
export PATH=/usr/local/cuda-9.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-9.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
  • 使用命令source .bashrc

  • 若使用tensorflow出现
    AttributeError: module ‘tensorflow.python.ops.nn’ has no attribute ‘rnn_cell’ #8049
    则卸载tensorflow,重新安装。

资料参考:
1. Install Nvidia CUDA-9.0 on Ubuntu 16.04 for Deep Learning
2. NVIDIA NVML Driver/library version mismatch

你可能感兴趣的:(深度学习笔记,tools)