转至:https://blog.csdn.net/asd85045625/article/details/80348270
安装Nvidia驱动
sudo ubuntu-drivers autoinstall #安装驱动
验证安装情况
nvidia-smi
安装CUDA8.0
在官网下载CUDA8.0.deb
进入下载目录后
sudo dpkg -i cuda-repo-ubuntu1704-8-0-local_9.0.176-1_amd64.deb
sudo apt-key add /var/cuda-repo-8-0-local-ga2/7fa2af80.pub
sudo apt-get update
sudo apt-get install aptitude
sudo aptitude install cuda
配置环境
sudo gedit ~/.bashrc
在最后两行
export PATH=/usr/local/cuda-8.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
保存,然后重启电脑 sudo reboot
测试CUDA的例子,需要编译一下
cd /usr/local/cuda-8.0/samples/1_Utilities/deviceQuery
sudo make
./deviceQuery
显示Result=pass,则测试通过,安装成功
安装CUDNN
进入下载文件夹
tar -zxvf cudnn-8.0-linux-x64-v5.tgz
sudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/include
sudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn*
安装tensorflow,指定版本安装
cuda 版本
cat /usr/local/cuda/version.txt
cudnn 版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2