TensorFlow Python2.7环境下的源码编译,一环境准备

参考:

https://blog.csdn.net/yhily2008/article/details/79967118

https://tensorflow.google.cn/install/install_sources

https://docs.python-guide.org/starting/install/osx/

代码获取:

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

一、为 macOS 准备环境

在构建 TensorFlow 之前,您必须在自己的系统中安装以下内容:

1. bazel:Bazel是google推出的一款工程编译工具,并且已经将其开源


2. TensorFlow Python 依赖项。


3. (可选)支持 GPU 的 TensorFlow 所需的 NVIDIA 软件包。


二、安装HomeBrew

/usr/bin/ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)”

安装完成后,修改~/.bash_profile,把brew的路径放置到路径前面。

export PATH="/usr/local/bin:/usr/local/sbin:$PATH"

三、安装Bazel

$ brew install bazel

Once installed, you can upgrade to a newer version of Bazel using the following command:

$ brew upgrade bazel

四、安装Python 2

https://docs.python-guide.org/starting/install/osx/

$ brew install python@2

修改~/.bash_profile,添加以下内容:

export PATH="/usr/local/opt/python@2/libexec/bin:$PATH"

五、安装 Python 依赖项

要构建 TensorFlow,您必须安装以下软件包:

1. six:一个专门用来兼容 Python 2 和 Python 3 的库


2. numpy:TensorFlow 需要的数值处理软件包。


3、wheel:用于管理 wheel (.whl) 格式的 Python 压缩包。


4、mock:Python中一个用于支持的测试的库

5、enum34:枚举模块

6、keras:一个用 Python 编写的高级神经网络 API

调用以下命令:

$ sudo pip2 install six numpy wheel mock enum34 keras