ubuntu14.04系统中安装tensorflow(gpu版)
来源:互联网 发布:网络维修平台 编辑:程序博客网 时间:2024/05/13 05:10
系统配置: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 toolkit
github下载tensorflow*.whl文件:tensorflow_GPU_py2.7 (拉到最下面选择GPU+py2)
官方下载:cuDNNV5(需要注册登录官网)
一共3个文件放入U盘,在ubuntu实体机上读取安装。这些文件全部放在/usr/local/WYLdownload目录下
第一步(可直接跳到第二步):安装nvidia显卡驱动
linux用户可以通过官方ppa解决安装GPU驱动的问题。使用如下命令添加Graphic Drivers PPA:
sudo add-apt-repository ppa:graphics-drivers/ppa然后更新源:
sudo apt-get update然后去navidia官网查看最新的驱动版本号:navidia官网:http://www.geforce.cn/drivers
比如说驱动的最新版本号为375,则执行如下指令:
sudo apt-get install nvidia-375最后安装openGL支持:
sudo apt-get install mesa-common-dev
第二步:安装cuda-toolkit-8.0并用其安装cuda-8.0
$ 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到环境变量:
sudo vim /etc/profile添加内容:
export CUDA_HOME=/usr/local/cuda-8.0export PATH=$CUDA_HOME/bin:$PATH export LD_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版本号最后一行为 <file:///usr/share/doc/gcc-4.8/README.Bugs>. 使用的ubuntu14.04使用的是4.8版本 所以不用降低gcc版本
sudo apt-get install g++-4.9sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 20sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-5 10sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 20sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-5 10sudo update-alternatives --install /usr/bin/cc cc /usr/bin/gcc 30sudo update-alternatives --set cc /usr/bin/gccsudo update-alternatives --install /usr/bin/c++ c++ /usr/bin/g++ 30sudo update-alternatives --set c++ /usr/bin/g++
第四步:下载 cuDNN V5+ 库文件并添加到cuda-8.0库
解压并将内容copy到/usr/local/cuda-8.0/include和lib64目录中:
指令如下:
sudo tar xvzf cudnn-8.0-linux-x64-v5.1.tgzsudo cp cuda/include/cudnn.h /usr/local/cuda-8.0/includesudo cp cuda/lib64/libcudnn* /usr/local/cuda-8.0/lib64sudo chmod a+r /usr/local/cuda-8.0/include/cudnn.h /usr/local/cuda-8.0/lib64/libcudnn* #分配包的权限
第五步:安装tensorflow(最简单的方式是第3种安装方法)
一、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运行环境
$ conda create -n tensorflow
2、Activate the conda environment by issuing the following command:激活conda环境
$ source activate tensorflow3、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
$ 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环境中退出:
$ source deactivate
二、git安装tensorflow
1、克隆Tensorflow仓库
#安转git支持:sudo apt-get install git
$ sudo git clone --recurse-submodules https://github.com/tensorflow/tensorflow /usr/local/WYLdownload/tensorflow$ pip install --upgrade setuptools pipgit clone <版本库的网址> <本地目录名>
即:上述指令是将git上的tensorflow包下载到ubuntu系统的/usr/local/WYLdownload/tensorflow包下
2、配置configure参数
$ sudo ./configure
三、pip安装tensoflow
$ pip install --ignore-installed --upgrade tensorflow_gpu-1.0.1-cp27-none-linux_x86_64.whl
四、Bazel安装tensorflow(如果选择用Bazel安装tensorfloe***.whl)
$ sudo add-apt-repository ppa:webupd8team/java$ sudo apt-get update$ sudo apt-get install oracle-java8-installer
$ 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-wheel3、安装源支持与bazel并更新bazel:
$ sudo apt-get update $ sudo apt-get install bazel$ sudo apt-get upgrade bazel
执行如下指令查看bazel是否安装完成:
$ bazel version
- ubuntu14.04系统中安装tensorflow(gpu版)
- ubuntu14.04系统中安装tensorflow(gpu版)
- ubuntu14.04+GPU安装TensorFlow
- ubuntu14.04系统中安装tensorflow(cpu版)
- ubuntu14.04系统中安装tensorflow(cpu版)
- ubuntu14.04安装GPU驱动、CUDA8.0、cudnn5、anaconda、tensorflow(GPU)
- tensorflow(GPU版)安装
- Linux系统下安装TensorFlow(CPU或者GPU版)
- win7系统安装GPU/CPU版tensorflow
- Tensorflow-GPU版本安装(Ubuntu14.04LTS+Cuda8+Quadro K1200)
- 简单安装tensorflow-gpu(GPU版tensorflow)
- TensorFlow安装(Ubuntu14.04)
- TensorFlow GPU版安装
- ubuntu14.04系统安装以及caffe无GPU安装
- Ubuntu14.04 安装Caffe(GPU)
- ubuntu14.04 + tensorflow(gpu版) + cuda-8.0 + cudnn(6.0) + keras
- Ubuntu14.04 安装 tensorflow
- ubuntu14.04安装TensorFlow
- OGRE 2.1 使用VS2015编译的过程以及问题的解决
- linux中用adduser和useradd命令创建用户有什么区别?
- 求n的阶乘的精确值
- sencha touch 给没有touch事件的控件添加touch事件
- android UI篇 进度条 progressbar
- ubuntu14.04系统中安装tensorflow(gpu版)
- Ubuntu 16.04安装ns2.35
- Hihocoder 1273 清理海报 DAG建图+几何
- HYSBZ
- alert confirm prompt
- UI层
- D
- 【3-1】探究操作系统
- IDEA中格式化代码快捷键