系统配置:ubuntu14.04 + GTX1060 + i7(7700K)
安装部署参考地址1:http://www.jb51.cc/article/p-uhgocanx-vb.html
安装部署参考地址2(推荐):http://blog.csdn.net/zhaoyu106/article/details/52793183
安装前准备工作(离线安装)
官方下载:cuda-8.0 toolkit
github下载tensorflow*.whl文件:tensorflow_GPU_py2.7 (拉到最下面选择GPU+py2)
官方下载:cuDNNV5(需要注册登录官网)
一共3个文件放入U盘,在ubuntu实体机上读取安装。这些文件全部放在/usr/local/WYLdownload目录下
第一步:安装nvidia显卡驱动
Linux用户可以通过官方ppa解决安装GPU驱动的问题。使用如下命令添加Graphic Drivers PPA:
- sudoadd-apt-repositoryppa:graphics-drivers/ppa
- sudoapt-getupdate
比如说驱动的最新版本号为375,则执行如下指令:
- sudoapt-getinstallnvidia-375
- sudoapt-getinstallmesa-common-dev
第二步:安装cuda-toolkit-8.0并用其安装cuda-8.0
- $sudodpkg-icuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb
- $sudoapt-getupdate
- $sudoapt-getinstallcuda
- exportCUDA_HOME=/usr/local/cuda-8.0
- exportPATH=$CUDA_HOME/bin:$PATH
- exportLD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
- source/etc/profile
- $nvidia-smi
下载cuda测试用例:下载到~/cuda_examples目录下
- $cuda-install-samples-8.0.sh~/cuda_examples
- $cd~/cuda_examples/NVIDIA_CUDA-8.0_Samples
- $make
第三步:降低gcc版本到5.0以下
- $gcc--help
- $gcc--version#查看gcc版本号
- $sudoapt-getinstallg++-4.9
- $sudoupdate-alternatives--install/usr/bin/gccgcc/usr/bin/gcc-4.920
- $sudoupdate-alternatives--install/usr/bin/gccgcc/usr/bin/gcc-510
- $sudoupdate-alternatives--install/usr/bin/g++g++/usr/bin/g++-4.920
- $sudoupdate-alternatives--install/usr/bin/g++g++/usr/bin/g++-510
- $sudoupdate-alternatives--install/usr/bin/cccc/usr/bin/gcc30
- $sudoupdate-alternatives--setcc/usr/bin/gcc
- $sudoupdate-alternatives--install/usr/bin/c++c++/usr/bin/g++30
- $sudoupdate-alternatives--setc++/usr/bin/g++
第四步:下载 cuDNN V5 库文件并添加到cuda-8.0库
解压并将内容copy到/usr/local/cuda-8.0/include和lib64目录中:
- $sudotarxvzfcudnn-8.0-linux-x64-v5.1.tgz
- $sudocpcuda/include/cudnn.h/usr/local/cuda-8.0/include
- $sudocpcuda/lib64/libcudnn*/usr/local/cuda-8.0/lib64
- $sudochmoda+r/usr/local/cuda-8.0/include/cudnn.h/usr/local/cuda-8.0/lib64/libcudnn*#分配包的权限
第五步:安装tensorflow
一、Anaconda安装tensorflow(不推荐conda目录和系统自带python目录冲突):
官方安装tensorflow说明:https://www.tensorflow.org/install
1、Create a conda environment named tensorflow to run a version of Python by invoking the following command:建立tensorflow运行环境
- $condacreate-ntensorflow
2、Activate the conda environment by issuing the following command:激活conda环境
- $sourceactivatetensorflow
$ pip install --ignore-installed --upgrade TF_PYTHON_URL
其中TF_PYTHON_URL是想要配置的tensorflow版本:
如:https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
- $sudopipinstall--ignore-installed--upgradehttps://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
4、从conda环境中退出:
- $sourcedeactivate
二、git安装tensorflow
1、克隆Tensorflow仓库
#安转Git支持:sudo apt-get install git
- $sudogitclone--recurse-submoduleshttps://github.com/tensorflow/tensorflow/usr/local/WYLdownload/tensorflow
- $pipinstall--upgradesetuptoolspip
即:上述指令是将git上的tensorflow包下载到ubuntu系统的/usr/local/WYLdownload/tensorflow包下
2、配置configure参数
- $sudo./configure
三、pip安装tensoflow
- $sudopipinstall--ignore-installed--upgradetensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
四、Bazel安装tensorflow(如果选择用Bazel安装tensorfloe***.whl)
- $sudoadd-apt-repositoryppa:webupd8team/java
- $sudoapt-getupdate
- $sudoapt-getinstalloracle-java8-installer
- $echo"deb[arch=amd64]http://storage.googleapis.com/bazel-aptstablejdk1.8"|sudotee/etc/apt/sources.list.d/bazel.list
- $curlhttps://bazel.build/bazel-release.pub.gpg|sudoapt-keyadd-
- $sudoapt-getinstallpython-numpyswigpython-devpython-wheel
- $sudoapt-getupdate
- $sudoapt-getinstallbazel
- $sudoapt-getupgradebazel
执行如下指令查看bazel是否安装完成:
- $bazelversion