I tried to build TensorFlow on my macOS. It was not difficult for me as a result. I could build the TensorFlow according to the official instruction. So I’ll add the tiny tips for building TensorFlow in addition to original instruction.
First you need to download the source code of TensorFlow. I downloaded TensorFlow under
GOPATH because it includes Go binding package
in the repository.
We can make use of Go infrastructures by installing here. (e.g. IDE plugins). So I recommend to install under
You need to install these dependencies first.
$ pyenv install anaconda3-4.2.0
It already includes required packages. Please try pyenv and anaconda for your Python environment. And you can install core utils with Homebrew.
$ brew install coreutils
Set configuration for building environment.
$ /path/to/tensorflow $ ./configure
In order to make compilation time shorter and avoid unnecessary build error, I disabled almost all configurations. If you want, please enable them with installing corresponding dependencies.
$ bazel build --config=opt //tensorflow/tools/pip_package:build_pip_package
It requires a lot of RAM and takes several minutes. The command generates the script for packaging. It puts the
.whl package under
$ bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
You can install the package in your Python environment as ordinal Python packages.
$ pip install /tmp/tensorflow_pkg/tensorflow-1.1.0-py2-none-any.whl
NOTE: Please move other workspace from the tensorflow repository otherwise you will see
not found package error.
>>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() >>> print(sess.run(hello))