ubuntu16.04+cuda8.0+cudnn6+tensorfolw安装教程

安装依赖包

sudo apt-get install openjdk-8-jdk git python-dev python3-dev python-numpy python3-numpy python-six python3-six build-essential python-pip python3-pip python-virtualenv swig python-wheel python3-wheel libcurl3-dev libcupti-dev

其中openjdk是必须的,不然在之后配置文件的时候会报错。

安装CUDA

nvidia官网下载cuda安装文件 https://developer.nvidia.com/cuda-downloads
赋予可执行权限

chmod +x cuda_8.0.44_linux.run

ctrl+alt+f1进入命令行界面 (不要慌,ctrl+alt+f7可以回到桌面来)

sudo service lightdm stop

注意: 一定要执行这个,否则安装过程会报错的

./cuda_8.0.44_linux.run

全部选择yes(其他教程会告诉你安装显卡驱动不用管,这里会自己安装驱动),安装完成后重启

sudo reboot

安装CUDNN

官网下载cudnn

cd /usr/local/cuda # cuDNN放在这个目录下解压
tar -xzvf cudnn-8.0-linux-x64-v6.0.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*

然后将将一下路径加入环境变量:

export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
export CUDA_HOME=/usr/local/cuda

即将上述代码放入~/.bashrc文件保存后source ~/.bashrc

安装Tensorflow

自从tensorflow 1.0版正式发布以后,安装已经非常容易,在安装CUDA和cuDNN之后,只需以下两步即可安装GPU版本的tf:

sudo apt-get install python-pip python-dev
pip install tensorflow-gpu

测试

python
import tensorflow as tf

常见问题

ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory
This problem is caused tensorflow-gpu-1.5 required cuda 9.0 ,so you should install tensorflow-gpu-1.4. And rember uninstall tensorflow-gpu-1.5. Please use this”

pip uninstall tensorflow-gpu
pip install --upgrade tensorflow-gpu==1.4

你可能感兴趣的:(深度学习,tensorflow,cuda,cudnn,ubuntu)