一、源代码编译
这里要为仅支持 CPU 的 TensorFlow 构建一个 pip 软件包,需要调用以下命令:
$ bazel build --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" --config=opt --verbose_failures //tensorflow/tools/pip_package:build_pip_package
 
提示:默认情况下,从源代码构建 TensorFlow 会消耗大量的 RAM。如果您系统中的 RAM 资源有限,则可以通过在调用 bazel 时指定 --local_resources 2048,.5,1.0 来限制 RAM 使用量。
 
编译期间因为缺少模块中断了几次,前后大概编译了几个小时,终于编译成功了!
Target //tensorflow/tools/pip_package:build_pip_package up-to-date:
  bazel-bin/tensorflow/tools/pip_package/build_pip_package
INFO: Elapsed time: 1226.516s, Critical Path: 54.42s
INFO: 904 processes: 904 local.
INFO: Build completed successfully, 1126 total actions
 
二、生成whl文件(.whl 文件的名称取决于您的平台)
bazel build 命令会构建一个名为 build_pip_package 的脚本。按如下所示运行此脚本后,一个 .whl 文件将在 /tmp/tensorflow_pkg 目录内构建:
➜  tensorflow git:(master) bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
 
2018年 8月13日 星期一 02时25分45秒 CST : === Preparing sources in dir: /var/folders/6v/q8bvbf3n209f0_59508px3pr0000gn/T/tmp.XXXXXXXXXX.nuoSUsnJ
/Volumes/DATA/AI/tensorflow /Volumes/DATA/AI/tensorflow
/Volumes/DATA/AI/tensorflow
2018年 8月13日 星期一 02时26分09秒 CST : === Building wheel
warning: no files found matching '*.dll' under directory '*'
warning: no files found matching '*.lib' under directory '*'
warning: no files found matching '*.h' under directory 'tensorflow/include/tensorflow'
warning: no files found matching '*' under directory 'tensorflow/include/Eigen'
warning: no files found matching '*.h' under directory 'tensorflow/include/google'
warning: no files found matching '*' under directory 'tensorflow/include/third_party'
warning: no files found matching '*' under directory 'tensorflow/include/unsupported'
2018年 8月13日 星期一 02时26分42秒 CST : === Output wheel file is in: /tmp/tensorflow_pkg
 
三、安装
首先找到具体的文件名称
➜  tensorflow git:(master) ll /tmp/tensorflow_pkg
total 98136
-rw-r--r--  1 mazhiyong  wheel    48M  8 13 02:26 tensorflow-1.10.0-cp27-cp27m-macosx_10_13_x86_64.whl
 
然后启动安装
➜  tensorflow git:(master) sudo pip2 install  /tmp/tensorflow_pkg/tensorflow-1.10.0-cp27-cp27m-macosx_10_13_x86_64.whl
 
四、验证
1、首先切换工作目录到tensorflow目录外,切记!
➜  tensorflow git:(master) cd ~
 
2、调用 Python2:
$ python2
 
3、验证
在 Python 交互式 shell 中输入以下几行简短的程序代码:
# Python
importtensorflow astf
hello =tf.constant('Hello, TensorFlow!')
sess =tf.Session()
print(sess.run(hello))
如果系统输出以下内容,就说明您可以开始编写 TensorFlow 程序了:
Hello, TensorFlow!
 
从二进制安装方式到源码编译方式前后折腾了两周,终于看到结果啦!
 

TensorFlow Python2.7环境下的源码编译(三)编译的更多相关文章

  1. TensorFlow Python2.7环境下的源码编译(二)安装配置

    源代码树的根目录中包含了一个名为 configure 的 bash 脚本. $ ./configure 接下来,配置系统会给出各种询问,以确认编译时的配置参数.   一.重要参数解释 Do you w ...

  2. TensorFlow Python2.7环境下的源码编译(一)环境准备

    参考: https://blog.csdn.net/yhily2008/article/details/79967118 https://tensorflow.google.cn/install/in ...

  3. TensorFlow Python3.7环境下的源码编译(三)编译

    这里要为仅支持 CPU 的 TensorFlow 构建一个 pip 软件包,需要调用以下命令: $ bazel build --cxxopt="-D_GLIBCXX_USE_CXX11_AB ...

  4. TensorFlow Python3.7环境下的源码编译(一)环境准备

    参考: https://blog.csdn.net/yhily2008/article/details/79967118 https://tensorflow.google.cn/install/in ...

  5. TensorFlow Python3.7环境下的源码编译(二)安装配置

    源代码树的根目录中包含了一个名为 configure 的 bash 脚本. $ ./configure 接下来,配置系统会给出各种询问,以确认编译时的配置参数.   一.重要参数解释 Please s ...

  6. Linux环境下levelDB源码编译与安装

    1.下载源码并编译 git clone https://github.com/google/leveldb.git cd leveldb //编译源码的时候需要安装cmake,并且版本需要大于3.9, ...

  7. 23 使用环境 UsageEnvironment——Live555源码阅读

    23 使用环境 UsageEnvironment——Live555源码阅读(三)UsageEnvironment 23 使用环境 UsageEnvironment——Live555源码阅读(三)Usa ...

  8. 基于Docker的TensorFlow机器学习框架搭建和实例源码解读

    概述:基于Docker的TensorFlow机器学习框架搭建和实例源码解读,TensorFlow作为最火热的机器学习框架之一,Docker是的容器,可以很好的结合起来,为机器学习或者科研人员提供便捷的 ...

  9. 25 BasicUsageEnvironment0基本使用环境基类——Live555源码阅读(三)UsageEnvironment

    25 BasicUsageEnvironment0基本使用环境基类——Live555源码阅读(三)UsageEnvironment 25 BasicUsageEnvironment0基本使用环境基类— ...

随机推荐

  1. 一个查询ip地址的mysql数据库--ip2nation

    http://ip2nation.com/ip2nation/Sample_Scripts/Country_Based_Redirect 并且已经集成进了laravel:https://github. ...

  2. PHP学习笔记一:谁动了你的mail(),PHP?

    PHP编写邮件发送的函数时候,会出现一个很奇怪的问题,那就是: Warning: mail(): Failed to connect to mailserver at "localhost& ...

  3. mac 安装npm

    npm是什么 NPM的全称是Node Package Manager ,是一个NodeJS包管理和分发工具,已经成为了非官方的发布Node模块(包)的标准. 如何安装 一:如果你安装了Homebrew ...

  4. DOS命令行简单用法

    DOS命令行简单用法 基本用法 1.cd(回车)从当前目录切回到根目录. 2.dir(回车)列出当前目录下的所有文件. 3.md kkk(回车)在当前目录下创建一个名称为kkk的文件夹. 4.rd k ...

  5. Python基础-画图:matplotlib

    Python画图主要用到matplotlib这个库.具体来说是pylab和pyplot这两个子库.这两个库可以满足基本的画图需求. pylab神器:pylab.rcParams.update(para ...

  6. python3 mock

    mock的官网学习备忘录:官网地址https://docs.python.org/3/library/unittest.mock.html#quick-guide 1,安装 python3 unitt ...

  7. 分别编写两个类Point2D,Point3D来表示二维空间和三维空间的点,使之满足下列要求:

    (1) Point2D有两个整型成员变量x, y (分别为二维空间的X,Y方向坐标),Point2D的构造方法要实现对其成员变量x, y的初始化. (2)Point2D有一个void型成员方法offs ...

  8. sed 替换有单引号的行

    cat test.txt $config['useragent'] = 'Roundcube Webmail'; // Hide version number//$config['username_d ...

  9. 使用iometer测试

    对国产机进行测试 1.win7上安装测试 下载: 点击打开链接 双击安装即可. 2.ubuntu下配置: OS: Ubuntu 12.04LTS x86_64Kernel: 3.5.0-26-gene ...

  10. java官网门户源码 SSM框架 自适应-响应式 freemarker 静态模版引擎

    来源:http://www.fhadmin.org/webnewsdetail3.html 前台:支持(5+1[时尚单页风格])六套模版,可以在后台切换 官网:www.fhadmin.org 系统介绍 ...