Ubuntu16.04下基于GeForce1060显卡配置tensorflow-gpu

摘要:笔者在多次踩坑之后总结出如题的tensorflow-gpu配置方法,亲测有用,若有不足,还望指正。

笔者开发使用:Ubuntu16.04+GeForce1060 +tensorflow-gpu+Python3.5+eclipse3.8。

 

1.Python2.7转Python3.5

sudo update-alternatives --install /usr/bin/python python /usr/bin/python2 0
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.5 300

 

 

2.安装pip

 

sudo apt-get install python3-pip

sudo pip3 install --upgrade pip

 

3.安装NVIDIA显卡驱动

检查版本:

ubuntu-drivers devices

这里是nvidia-375,安装

sudo apt-get install nvidia-375

重启

 

4.安装CUDA

官网下载:https://developer.nvidia.com/cuda-downloads
这里下载的是cuda_8.0.61_375.26_linux.run
安装:

 

sudo sh ~/Downloads/cuda_8.0.61_375.26_linux.run --override

 

具体操作:

CTRL+C跳过介绍

Do you accept the previously read EULA?
accept/decline/quit: accept

Install NVIDIA Accelerated Graphics Driver for Linux-x86_64 367.48?
(y)es/(n)o/(q)uit: n

Install the CUDA 8.0 Toolkit?
(y)es/(n)o/(q)uit: y

Enter Toolkit Location
 [ default is /usr/local/cuda-8.0 ]:  

Do you want to install a symbolic link at /usr/local/cuda?
(y)es/(n)o/(q)uit: y

Install the CUDA 8.0 Samples?
(y)es/(n)o/(q)uit: y

Enter CUDA Samples Location [ default is /home/用户名 ]:

装完后显示:
===========
= Summary =
===========
等内容

 

5.安装cuDNN

官网下载:https://developer.nvidia.com/cudnn
这里用的是:cudnn-8.0-linux-x64-v5.1.tgz
安装:

cd /usr/local
sudo tar -xzvf ~/Downloads/cudnn-8.0-linux-x64-v5.1.tgz

 

6.配置环境变量

 

 

gedit ~/.bashrc

添加:
export PATH=/usr/local/cuda-8.0/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:/usr/local/cuda-8.0/extras/CUPTI/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/usr/local/cuda-8.0
编译一下:

source ~/.bashrc

 

7.下载tensorflow-gpu

 

 

export TF_BINARY_URL=https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.2.0rc0-cp35-cp35m-linux_x86_64.whl
sudo pip install --upgrade $TF_BINARY_URL

试一下:

python
>>>import tensorflow

 

8.安装jdk1.8(暂时非必需)

 

 

sudo add-apt-repository ppa:openjdk-r/ppa
sudo apt-get update
sudo apt-get install openjdk-8-jdk

 

9.安装eclipse,配置Pydev

 

 

sudo apt-get install eclipse

配置pydev:
打开eclipse:
终端输入:eclipse
help-->install new software-->add-->name:Pydev;location:http://pydev.org/update_sites/4.5.5-->select all-->next-->......
配置解释器:
window-->preferences-->Pydev-->interpreters--->python interpreter-->new-→browse-->file system-->/usr/bin/python3.5-->OK-->......

 

10.常见错误(不定期更新)

×ImportError: libcudart.so.8.0: cannot open shared object file: No such file or directory

参考:http://blog.csdn.net/liuyifang0810680/article/details/53008698

×Check failed: s.ok() could not find cudnnCreate in cudnn DSO

参考:http://www.linuxdiyf.com/linux/16684.html

×升级tensorflow1.1版本后,ImportError: libcufft.so.8.0: cannot open shared object file: No such file or directory

终端输入:

 

sudo cp '/usr/local/cuda-8.0/lib64/libcufft.so.8.0' '/usr/lib'

 

结束语:若有错误之处,欢迎指正。。。。。。

 

 

 

 

你可能感兴趣的:(环境配置)