一、源代码编译
这里要为仅支持 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. elif 相当于else&if

    if  条件: 语句块 elif 条件: 语句块 ... else                      #elif好像要有一个else作为结尾

  2. Servlet 启动顺序

    在servlet的配置当中,<load-on-startup>1</load-on-startup>的含义是: 标记容器是否在启动的时候就加载这个servlet. 当值为0或者 ...

  3. [Java多线程] LinkedBlockingQueue

    java.util.concurrent包下的新类.LinkedBlockingQueue就是其中之一,是一个阻塞的线程安全的队列,底层采用链表实现. LinkedBlockingQueue Link ...

  4. 《信息安全技术》实验二 Windows口令破解

    <信息安全技术>实验二 Windows口令破解 实验目的 了解Windows口令破解原理 对信息安全有直观感性认识 能够运用工具实现口令破解 实验环境 实验机Windows Server ...

  5. C# 生成自签名CA证书

    "; string signatureAlgorithm = "SHA1WithRSA"; // Generate RSA key pair var rsaGenerat ...

  6. swoole_table应用类

    <?php/* Redis可真能坑爷,原先的设计用redis保存临时数据,可到了实际应用(实际上也就是几十个人同时用),总是出现莫名其妙的问题,最常见的就是读不出数据来,调试了好多天,那问题还是 ...

  7. c++ const static

    const作用: 1.定义常量,可以保护被修饰的东西,防止意外的修改,增强程序的健壮性. const int Max = 100; void f(const int i) { i=10;//error ...

  8. 一维maxpooling

    index存储的是下标 vector<int> maxpooling(vector<int> num,int size){ vector<int> result; ...

  9. leetcode 217. Contains Duplicate 287. Find the Duplicate Number 442. Find All Duplicates in an Array 448. Find All Numbers Disappeared in an Array

    后面3个题都是限制在1-n的,所有可以不先排序,可以利用巧方法做.最后两个题几乎一模一样. 217. Contains Duplicate class Solution { public: bool ...

  10. vmvare安装系统提示vmci.sys 版本不正确解决方法

    无法获取vmci驱动程序版本:参数不正确解决 无法获取vmci驱动程序版本:参数不正确. 驱动程序vmci.sys版本不正确. 解决办法: 1,创建好虚拟机之后,别打开电源,然后到建好的虚拟机文件夹里 ...