ubuntu14.04系统中安装tensorflow(gpu版)
2017-05-10 11:33
281 查看
原文:http://blog.csdn.net/u012969412/article/details/64502393
系统配置:ubuntu14.04 + GTX1060 + i7(7700K)
安装部署参考地址1:http://blog.csdn.net/zhouchao_fight/article/details/51517338
安装部署参考地址2(推荐):http://blog.csdn.net/zhaoyu106/article/details/52793183
github下载tensorflow*.whl文件:tensorflow_GPU_py2.7 (拉到最下面选择GPU+py2)
官方下载:cuDNNV5(需要注册登录官网)
一共3个文件放入U盘,在ubuntu实体机上读取安装。这些文件全部放在/usr/local/WYLdownload目录下
[python]
view plain
copy
sudo add-apt-repository ppa:graphics-drivers/ppa
然后更新源:
[python]
view plain
copy
sudo apt-get update
然后去navidia官网查看最新的驱动版本号:navidia官网:http://www.geforce.cn/drivers
比如说驱动的最新版本号为375,则执行如下指令:
[python]
view plain
copy
sudo apt-get install nvidia-375
最后安装openGL支持:
[python]
view plain
copy
sudo apt-get install mesa-common-dev
官方网站下载:CUDA Toolkit 8.0。下载网址为:https://developer.nvidia.com/cuda-downloads
然后执行如下指令:
[python]
view plain
copy
$ sudo dpkg -i cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb
$ sudo apt-get update
$ sudo apt-get install cuda
这时在/usr/local目录下产生一个cuda安装的路径叫"cuda-8.0"添加cuda到环境变量:
[python]
view plain
copy
sudo vim /etc/profile
添加内容:
[python]
view plain
copy
export CUDA_HOME=/usr/local/cuda-8.0
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
使环境变量生效
[python]
view plain
copy
source /etc/profile
检验是否安装成功:查看GPU运行的进程
参考测试网址:http://blog.csdn.net/masa_fish/article/details/51882183
[python]
view plain
copy
$ nvidia-smi
下载cuda测试用例:下载到~/cuda_examples目录下
[python]
view plain
copy
$ cuda-install-samples-8.0.sh ~/cuda_examples
运行测试用例:
[python]
view plain
copy
$ cd ~/cuda_examples/NVIDIA_CUDA-8.0_Samples
$ make
[python]
view plain
copy
$ gcc --help
[python]
view plain
copy
$ gcc --version #查看gcc版本号
最后一行为 <file:///usr/share/doc/gcc-4.8/README.Bugs>. 使用的ubuntu14.04使用的是4.8版本 所以不用降低gcc版本
否则执行如下指令:
[python]
view plain
copy
$ sudo apt-get install g++-4.9
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
$ sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
$ sudo update-alternatives --set cc /usr/bin/gcc
$ sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
$ sudo update-alternatives --set c++ /usr/bin/g++
网址为:https://developer.nvidia.com/rdp/cudnn-archive
解压并将内容copy到/usr/local/cuda-8.0/include和lib64目录中:
[python]
view plain
copy
$ sudo tar xvzf cudnn-8.0-linux-x64-v5.1.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-8.0/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn* #分配包的权限
1、Create a conda environment named tensorflow to run a version of
Python by invoking the following command:建立tensorflow运行环境
[python]
view plain
copy
$ conda create -n tensorflow
2、Activate the conda environment by issuing the following command:激活conda环境
[python]
view plain
copy
$ source activate tensorflow
3、Issue a command of the following format to install TensorFlow inside your conda environment:
$ 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
[python]
view plain
copy
$ sudo pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
4、从conda环境中退出:
[python]
view plain
copy
$ source deactivate
#安转Git支持:sudo apt-get install git
[python]
view plain
copy
$ sudo git clone --recurse-submodules https://github.com/tensorflow/tensorflow /usr/local/WYLdownload/tensorflow
$ pip install --upgrade setuptools pip
git clone <版本库的网址> <本地目录名>
即:上述指令是将git上的tensorflow包下载到ubuntu系统的/usr/local/WYLdownload/tensorflow包下
2、配置configure参数
[python]
view plain
copy
$ sudo ./configure
[python]
view plain
copy
$ sudo pip install --ignore-installed --upgrade tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
1、首先安装jdk1.8: http://blog.csdn.net/u012969412/article/details/58056270
但是bazel需要的jdk非以上jdk。需要oracle自己的jdk8包。
[python]
view plain
copy
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
2、安装Bazel依赖:
[python]
view plain
copy
$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
$ sudo apt-get install python-numpy swig python-dev python-wheel
3、安装源支持与bazel并更新bazel:
[python]
view plain
copy
$ sudo apt-get update
$ sudo apt-get install bazel
$ sudo apt-get upgrade bazel
执行如下指令查看bazel是否安装完成:
[python]
view plain
copy
$ bazel version
往后略可以看官网
系统配置:ubuntu14.04 + GTX1060 + i7(7700K)
安装部署参考地址1:http://blog.csdn.net/zhouchao_fight/article/details/51517338
安装部署参考地址2(推荐):http://blog.csdn.net/zhaoyu106/article/details/52793183
安装前准备工作(离线安装)
官方下载:cuda-8.0 toolkitgithub下载tensorflow*.whl文件:tensorflow_GPU_py2.7 (拉到最下面选择GPU+py2)
官方下载:cuDNNV5(需要注册登录官网)
一共3个文件放入U盘,在ubuntu实体机上读取安装。这些文件全部放在/usr/local/WYLdownload目录下
第一步:安装nvidia显卡驱动
Linux用户可以通过官方ppa解决安装GPU驱动的问题。使用如下命令添加Graphic Drivers PPA:[python]
view plain
copy
sudo add-apt-repository ppa:graphics-drivers/ppa
然后更新源:
[python]
view plain
copy
sudo apt-get update
然后去navidia官网查看最新的驱动版本号:navidia官网:http://www.geforce.cn/drivers
比如说驱动的最新版本号为375,则执行如下指令:
[python]
view plain
copy
sudo apt-get install nvidia-375
最后安装openGL支持:
[python]
view plain
copy
sudo apt-get install mesa-common-dev
第二步:安装cuda-toolkit-8.0并用其安装cuda-8.0
如果直接执行:$ sudo apt-get install -y cuda 会报错。正确使用方法为。官方网站下载:CUDA Toolkit 8.0。下载网址为:https://developer.nvidia.com/cuda-downloads
然后执行如下指令:
[python]
view plain
copy
$ sudo dpkg -i cuda-repo-ubuntu1404-8-0-local-ga2_8.0.61-1_amd64.deb
$ sudo apt-get update
$ sudo apt-get install cuda
这时在/usr/local目录下产生一个cuda安装的路径叫"cuda-8.0"添加cuda到环境变量:
[python]
view plain
copy
sudo vim /etc/profile
添加内容:
[python]
view plain
copy
export CUDA_HOME=/usr/local/cuda-8.0
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
使环境变量生效
[python]
view plain
copy
source /etc/profile
检验是否安装成功:查看GPU运行的进程
参考测试网址:http://blog.csdn.net/masa_fish/article/details/51882183
[python]
view plain
copy
$ nvidia-smi
下载cuda测试用例:下载到~/cuda_examples目录下
[python]
view plain
copy
$ cuda-install-samples-8.0.sh ~/cuda_examples
运行测试用例:
[python]
view plain
copy
$ cd ~/cuda_examples/NVIDIA_CUDA-8.0_Samples
$ make
第三步:降低gcc版本到5.0以下
查看gcc当前使用版本:[python]
view plain
copy
$ gcc --help
[python]
view plain
copy
$ gcc --version #查看gcc版本号
最后一行为 <file:///usr/share/doc/gcc-4.8/README.Bugs>. 使用的ubuntu14.04使用的是4.8版本 所以不用降低gcc版本
否则执行如下指令:
[python]
view plain
copy
$ sudo apt-get install g++-4.9
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20
$ sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20
$ sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10
$ sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30
$ sudo update-alternatives --set cc /usr/bin/gcc
$ sudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30
$ sudo update-alternatives --set c++ /usr/bin/g++
第四步:下载 cuDNN V5 库文件并添加到cuda-8.0库
到官网下载:cudnn-7.0-linux-x64-v3.0.8-prod.tgz网址为:https://developer.nvidia.com/rdp/cudnn-archive
解压并将内容copy到/usr/local/cuda-8.0/include和lib64目录中:
[python]
view plain
copy
$ sudo tar xvzf cudnn-8.0-linux-x64-v5.1.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-8.0/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn* #分配包的权限
第五步:安装tensorflow
一、Anaconda安装tensorflow(不推荐conda目录和系统自带python目录冲突):
官方安装tensorflow说明:https://www.tensorflow.org/install1、Create a conda environment named tensorflow to run a version of
Python by invoking the following command:建立tensorflow运行环境
[python]
view plain
copy
$ conda create -n tensorflow
2、Activate the conda environment by issuing the following command:激活conda环境
[python]
view plain
copy
$ source activate tensorflow
3、Issue a command of the following format to install TensorFlow inside your conda environment:
$ 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
[python]
view plain
copy
$ sudo pip install --ignore-installed --upgrade https://storage.googleapis.com/tensorflow/linux/gpu/tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
4、从conda环境中退出:
[python]
view plain
copy
$ source deactivate
二、git安装tensorflow
1、克隆Tensorflow仓库#安转Git支持:sudo apt-get install git
[python]
view plain
copy
$ sudo git clone --recurse-submodules https://github.com/tensorflow/tensorflow /usr/local/WYLdownload/tensorflow
$ pip install --upgrade setuptools pip
git clone <版本库的网址> <本地目录名>
即:上述指令是将git上的tensorflow包下载到ubuntu系统的/usr/local/WYLdownload/tensorflow包下
2、配置configure参数
[python]
view plain
copy
$ sudo ./configure
三、pip安装tensoflow
在文件目录下执行:[python]
view plain
copy
$ sudo pip install --ignore-installed --upgrade tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
四、Bazel安装tensorflow(如果选择用Bazel安装tensorfloe***.whl)
Bazel是一个类似于Make的工具,是Google为其内部软件开发的特点量身定制的工具,如今Google使用它来构建内部大多数的软件。1、首先安装jdk1.8: http://blog.csdn.net/u012969412/article/details/58056270
但是bazel需要的jdk非以上jdk。需要oracle自己的jdk8包。
[python]
view plain
copy
$ sudo add-apt-repository ppa:webupd8team/java
$ sudo apt-get update
$ sudo apt-get install oracle-java8-installer
2、安装Bazel依赖:
[python]
view plain
copy
$ echo "deb [arch=amd64] http://storage.googleapis.com/bazel-apt stable jdk1.8" | sudo tee /etc/apt/sources.list.d/bazel.list
$ curl https://bazel.build/bazel-release.pub.gpg | sudo apt-key add -
$ sudo apt-get install python-numpy swig python-dev python-wheel
3、安装源支持与bazel并更新bazel:
[python]
view plain
copy
$ sudo apt-get update
$ sudo apt-get install bazel
$ sudo apt-get upgrade bazel
执行如下指令查看bazel是否安装完成:
[python]
view plain
copy
$ bazel version
往后略可以看官网
相关文章推荐
- ubuntu14.04系统中安装tensorflow(gpu版)cuda-8.0 + cudann(5.0 or 6.0)
- TensorFlow-GPU环境配置之一——安装Ubuntu双系统
- Tensorflow-GPU版本安装(Ubuntu14.04LTS+Cuda8+Quadro K1200)
- ubuntu14.04安装GPU驱动、CUDA8.0、cudnn5、anaconda、tensorflow(GPU)
- Tensorflow1.0+ubuntu14.04+GPU安装
- Ubuntu 14.04 64bit 安装tensorflow(GPU版本)
- ubuntu16.04系统下CUDA8.0和CUDNN6.0和tensorflow(GPU)的安装
- ubuntu14.04安装TensorFlow-gpu1.0.1
- ubuntu14.04系统中安装tensorflow(cpu版)
- ubuntu14.04系统安装以及caffe无GPU安装
- [置顶] Ubuntu14.04安装cuda8.0+cudnn5.1+Tensorflow1.0.0(GPU)教程
- Ubuntu 14.04 安装 CUDA8.0 cudnn 5.1 tensorflow1.2.1GPU
- ubuntu14.04+GPU安装TensorFlow
- ubuntu14.04系统中安装tensorflow(cpu版)
- Theano、Lasagne、TensorFlow在Ubuntu14.04 64支持GPU的安装 py27
- [视频]mac系统下虚拟机parallels安装ubuntu 14.04视频教程
- Ubuntu 14.04系统安装ThinkPad X201s指纹设备驱动
- mac系统下虚拟机parallels安装ubuntu 14.04
- pandaboard安装ubuntu14.04系统遇到的问题
- 安装单系统ubuntu14.04