参考博客:http://blog.csdn.net/zhaoyu106/article/details/52793183/,
http://blog.csdn.net/u010900574/article/details/52201808
由于我之前已经配置过cuda8.0和cudnn5.1.10所以不用安装了
1、安装bazel
点击链接: installer for your system,跳转到Bazel的下载页面:
下载bazel-0.7.0-installer-linux-x86_64.sh到桌面,下载最新版的,不用和我的一致,然后在terminal中输入以下命令
cd  /home/***(自己的用户名)/Desktop/###(这个命令意思是找到刚刚我们用U盘传过来的文件)
chmod +x PATH_TO_INSTALL.SH #对.sh文件授权
./PATH_TO_INSTALL.SH --user #运行.sh文件

2、安装第三方库

在terminal中输入以下命令

sudo apt-get install python-numpy swig python-dev python-wheel #安装第三方库
sudo apt-get install git
git clone git://github.com/numpy/numpy.git numpy

3、安装tensorflow

在terminal中输入以下命令

git clone https://github.com/tensorflow/tensorflow

在terminal中输入以下命令:

cd ~/tensorflow #切换到tensorflow文件夹
./configure #执行configure文件
Do you wish to use jemalloc as the malloc implementation? [Y/n] y
jemalloc enabled
Do you wish to build TensorFlow with Google Cloud Platform support? [y/N] n
No Google Cloud Platform support will be enabled for TensorFlow
Do you wish to build TensorFlow with Hadoop File System support? [y/N] n
No Hadoop File System support will be enabled for TensorFlow
Do you wish to build TensorFlow with the XLA just-in-time compiler (experimental)? [y/N] n
No XLA JIT support will be enabled for TensorFlow
Found possible Python library paths:
/usr/lib/python2.7/site-packages
/usr/lib64/python2.7/site-packages
Please input the desired Python library path to use. Default is [/usr/lib/python2.7/site-packages] Using python library path: /usr/lib/python2.7/site-packages
Do you wish to build TensorFlow with OpenCL support? [y/N] n
No OpenCL support will be enabled for TensorFlow
Do you wish to build TensorFlow with CUDA support? [y/N] y
CUDA support will be enabled for TensorFlow
Please specify which gcc should be used by nvcc as the host compiler. [Default is /usr/bin/gcc]:
Please specify the CUDA SDK version you want to use, e.g. 7.0. [Leave empty to use system default]: 8.0
Please specify the location where CUDA 8.0 toolkit is installed. Refer to README.md for more details. [Default is /usr/local/cuda]: /usr/local/cuda-8.0

4、创建pip

在tensorflow的根目录下,在terminal中输入以下命令:
bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
sudo pip install /home/***(你自己的用户名)/Desktop/tensorflow-0.10.0-cp2-none-any.whl

tensorflow-0.10.0-cp2-none-any.whl要根据你下载的文件名有所更改。

5、设置tensorflow环境

bazel build -c opt //tensorflow/tools/pip_package:build_pip_package
# To build with GPU support:
bazel build -c opt --config=cuda //tensorflow/tools/pip_package:build_pip_package
mkdir _python_build
cd _python_build
ln -s ../bazel-bin/tensorflow/tools/pip_package/build_pip_package.runfiles/org_tensorflow/* .
ln -s ../tensorflow/tools/pip_package/* .
python setup.py develop

6、tensorflow测试

$ python

>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
>>> print sess.run(hello)
Hello, TensorFlow!
>>> a = tf.constant(10)
>>> b = tf.constant(32)
>>> print sess.run(a+b)
42
>>>

大功告成

出现的错误
操作
bazel build -c opt --config=cuda //tensorflow/cc:tutorials_example_trainer

报错

ERROR: /home/yaroslavvb/tensorflow.git/tensorflow/tensorflow/core/kernels/BUILD:1080:1: undeclared inclusion(s) in rule '//tensorflow/core/kernels:cwise_op_gpu':
this is missing dependency dependency for following files included by 'tensorflow/core/kernels/cwise_op_gpu_floor.cu.cc':
'/usr/local/cuda-8.0/include/cuda_runtime.h'
'/usr/local/cuda-8.0/include/host_config.h'
'/usr/local/cuda-8.0/include/builtin_types.h'
'/usr/local/cuda-8.0/include/device_types.h'
'/usr/local/cuda-8.0/include/host_defines.h'
'/usr/local/cuda-8.0/include/driver_types.h'
'/usr/local/cuda-8.0/include/surface_types.h'
'/usr/local/cuda-8.0/include/texture_types.h'

可以进入tensorflow/third_party/gpus/crosstool/目录,打开CROSSTOOL文件,搜索cxx_builtin_include_directory,应该有三行,在下面添加行如下
cxx_builtin_include_directory: "/usr/local/cuda-8.0/include"

如果出现的错误是类似的,只要将cxx_builtin_include_directory: "/usr/local/cuda-8.0/include"的文件路径改一下就可以了,亲测有效

再次运行上一步的命令,应该就没问题了。

ubuntu16.04 源码方法安装tensorflow的更多相关文章

  1. ubuntu16.04源码编译安装wine1.8.6安装不上引来的错误

    configure: libxcomposite 64-bit development files not found, Xcomposite won't be supported. configur ...

  2. ubuntu16.04源码编译安装nginx1.14.2

    1.下载nginx-1.14.2, 官网地址:nginx.org 2.解压nginx-1.14.2.tar.gz tar zxvf nginx-1.14.2.tar.gz 3.切到文件夹nginx-1 ...

  3. [笔记] Ubuntu 18.04源码编译安装OpenCV 4.0流程

    标准常规安装方法安装的OpenCV版本比较低,想尝鲜使用4.0版本,只好源码安装. 安装环境 OS:Ubuntu 18.04 64 bit 显卡:NVidia GTX 1080 CUDA:10.0 c ...

  4. centos7 源码编译安装TensorFlow CPU 版本

    一.前言 我们都知道,普通使用pip安装的TensorFlow是万金油版本,当你运行的时候,会提示你不是当前电脑中最优的版本,特别是CPU版本,没有使用指令集优化会让TensorFlow用起来更慢. ...

  5. ubuntu16.04 源码安装Python3.7 (可以在此基础上安装Tensorflow) (确保Tensorflow计算框架与系统的彻底隔离)

    Python3.7 源码下载: https://www.python.org/downloads/release/python-370/ 解压源码: tar -zxvf Python-3.7.0.tg ...

  6. windows10下如何进行源码编译安装tensorflow

    1.获取python3.5.x https://www.python.org/ftp/python/3.5.4/python-3.5.4-amd64.exe 2.安装python3.5.x,默认安装即 ...

  7. Ubuntu 16.04 源码编译安装PHP7+swoole

    备注: Ubuntu 16.04 Server 版安装过程图文详解 Ubuntu16镜像地址: 链接:https://pan.baidu.com/s/1XTVS6BdwPPmSsF-cYF6B7Q 密 ...

  8. Mac下使用源码编译安装TensorFlow CPU版本

    1.安装必要的软件 1.1.安装JDK 8 (1)JDK 8 can be downloaded from Oracle's JDK Page: http://www.oracle.com/techn ...

  9. Ubuntu 16.04 源码编译安装PHP7

    一.下载PHP7的最新版源码 php7.0.9  下载地址 http://php.net/get/php-7.0.9.tar.gz/from/a/mirror 二.解压 tar -zxf /tmp/p ...

随机推荐

  1. 对final和static的理解

    一.final (一).final的使用 final关键字可以用来修饰类.方法和变量(包括成员变量和局部变量) 1. 当用final修饰一个类时,表明这个类不能被继承.2. 当用final修饰一个方法 ...

  2. Sametime SDK

    1,Sametime Server A.Sametime includes many server applications, which collectively provide the capab ...

  3. hdu-3308 LCIS (线段树区间合并)

    LCIS Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  4. hdu1542 Atlantis (线段树+矩阵面积并+离散化)

    There are several ancient Greek texts that contain descriptions of the fabled island Atlantis. Some ...

  5. 数字表格(product)

    Description Solution 一开始的时候我是这么推的(\(f(n)\)表示斐波那契数列的第\(n\)项) \[ \begin{aligned} Ans&=\prod_{x=1}^ ...

  6. 遇到问题----java----myeclipse或者eclipse发布的项目时配置文件不更新或者无配置文件

    myeclipse或者eclipse发布的项目时配置文件不更新或者无配置文件. 正常的web项目有目录 src/main/resources 和 src/main/java 这两个目录默认在编译发布时 ...

  7. Luogu P3251 [JLOI2012]时间流逝 期望dp

    题面 题面 题解 期望\(dp\)好题! 今年\(ZJOI\)有讲过这题... 首先因为\(T\)只有\(50\),大力\(dfs\)后发现,可能的状态数最多只有\(20w\)左右,所以我们就可以大力 ...

  8. Lnmp上安装Yaf学习(一)

    今天学习Lnmp上面如何安装Yaf流程 一.安装Lnmp 集成环境 访问路径:https://lnmp.org/install.html 这里我安装稳定版lnmp 1)   wget -c http: ...

  9. UIImage加载图片的方式以及Images.xcassets对于加载方法的影响

    UIImage加载图片的方式以及Images.xcassets对于加载方法的影响 图片缓存 根据是否将创建好的对象缓存入系统内存,有两类创建UIImage对象的方法可选: 缓存:+ imageName ...

  10. Chapter10(泛型算法)--C++Prime笔记

    关键:算法通过在迭代器上进行操作来实现类型无关.算法不改变所操作序列的大小. 1.算法大多都定义在algorithm头文件中,标准库还在头文件numeric中定义了一组数值泛型算法. 2.泛型算法永远 ...