1.安装cuda
cd /home/*(自己的用户名)/Desktop/###(进入cuda所在文件夹)
sudo dpkg -i cuda-repo-ubuntu1604-8-0-rc_8.0.27-1_amd64.deb
sudo apt-get update
sudo apt-get install cuda
2.安装cudnn
cd /home/*(自己的用户名)/Desktop/###(进入cudnn所在文件夹)
tar xvzf cudnn-8.0-linux-x64-v5.1-ga.tgz###
sudo cp cuda/include/cudnn.h /usr/local/cuda/include###
sudo cp cuda/lib64/libcudnn* /usr/local/cuda/lib64###
sudo chmod a+r /usr/local/cuda/include/cudnn.h /usr/local/cuda/lib64/libcudnn*
3.配置环境变量
sudo gedit ~/.bashrc
export LD_LIBRARY_PATH=”$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64”
export CUDA_HOME=/usr/local/cuda
source ~/.bashrc #使更改的环境变量生效
4.安装tensorflow
sudo apt-get install python-pip python-dev
export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.1-cp27-none-linux_x86_64.whl
sudo pip install –upgrade $TF_BINARY_URL