一、源代码编译
这里要为仅支持 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. codeforces 741D Arpa’s letter-marked tree and Mehrdad’s Dokhtar-kosh paths(启发式合并)

    codeforces 741D Arpa's letter-marked tree and Mehrdad's Dokhtar-kosh paths 题意 给出一棵树,每条边上有一个字符,字符集大小只 ...

  2. ES6中map和set用法

    ES6中map和set用法 --转载自廖雪峰的官方网站 一.map Map是一组键值对的结构,具有极快的查找速度. 举个例子,假设要根据同学的名字查找对应的成绩,如果用Array实现,需要两个Arra ...

  3. PHP设计模式系列 - 外观模式

    外观模式 通过在必需的逻辑和方法的集合前创建简单的外观接口,外观设计模式隐藏了调用对象的复杂性. 外观设计模式和建造者模式非常相似,建造者模式一般是简化对象的调用的复杂性,外观模式一般是简化含有很多逻 ...

  4. 安装VMware,Linux

    不是每一个程序员都必须玩过linux,只是博主觉得现在的很多服务器都是linux系统的,而自己属于那种前端也搞,后台也搞,对框架搭建也感兴趣,但是很多生产上的框架和工具都是安装在服务器上的,而且有不少 ...

  5. struts2 标签使用注意

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/qilixiang012/article/details/31954501 通常是用html标签.而不 ...

  6. JavaScript组合继承的一点思考

    今天看<JavaScript高级程序设计>一书中关于组合继承模式时.书上有这么一个Demo程序: <html> <head> </head> <b ...

  7. 【洛谷】【lca+树上差分】P3258 [JLOI2014]松鼠的新家

    [题目描述:] 松鼠的新家是一棵树,前几天刚刚装修了新家,新家有n(2 ≤ n ≤ 300000)个房间,并且有n-1根树枝连接,每个房间都可以相互到达,且俩个房间之间的路线都是唯一的.天哪,他居然真 ...

  8. [原创]升级Gerrit的commit-msg,检查git commit时必须填写开发任务编号TaskID

    公司使用git+gerrit+jenkins进行持续集成实践,其中gerrit用来进行Code Review.另外我们自己研发了一套敏捷项目管理系统TPM(TeamPlus Management),用 ...

  9. js 继承的几种方式

    JS继承的实现方式: 既然要实现继承,那么首先我们得有一个父类,代码如下: function Animal(name) { // 属性 this.name = name || '小白'; // 实例方 ...

  10. 记录一下安装 mysql 的踩坑之路

    坑点: 1.旧的mysql没有删除干净.在安装mysql的时候,没有注意到,在输入 “mysqld install” 指令时跳出来 exits,存在于另一个文件夹之中,这影响了后来的很多操作,包括ro ...