Skip to content

Instantly share code, notes, and snippets.

@ryan-williams
Last active March 12, 2019 20:42
Show Gist options
  • Save ryan-williams/e53a3613d08d633c92e249f75380bb20 to your computer and use it in GitHub Desktop.
Save ryan-williams/e53a3613d08d633c92e249f75380bb20 to your computer and use it in GitHub Desktop.
Instructions for building+testing Tensorflow (1.13.1) on macOS with Bazel 0.22.0

I was trying "Run the tests", and saw some failures, apparently due to having GCC linked under gcc/g++ instead of clang, on macOS:

ERROR: /private/var/tmp/_bazel_ryan/b82c47e810a34e3560644976a9c6bf6f/external/protobuf_archive/BUILD:626:1: Linking of rule '@protobuf_archive//:python/google/protobuf/internal/_api_implementation.so' failed (Exit 1)
gcc: error: unrecognized command line option '-fobjc-link-runtime'; did you mean '-fgnu-runtime'?

Specifying clang in the CC env var seemed to work:

CC=clang bazel test -c opt -- //tensorflow/... -//tensorflow/compiler/... -//tensorflow/lite/...

This comment pointed me to this fix: bazelbuild/bazel#4077 (comment)

For completeness:

Attempted "batteries included" macOS quickstart:

Using Bazel 0.22.0 (via brew)

brew install bazel
bazel --version

Clone:

git clone [email protected]:tensorflow/tensorflow.git
cd tensorflow

Checkout latest release, apply patches

git checkout v1.13.1
git cherry-pick 8c22259497e9914c37a7adcd33aebaf754473a02  # upgrade something related to protobufs
git cherry-pick 91da898cb6f6b0e751e15ceb813a37cdfe18a035  # bump max bazel version to 0.22.0

Configure

Defaults seem fine:

yes "" | ./configure

Build

CC=clang bazel build -c opt -- //tensorflow/... -//tensorflow/compiler/... -//tensorflow/lite/...

This command took 45mins on an 8-core macbook, and ran 14k targets, iirc.

Test

CC=clang bazel test -c opt -- //tensorflow/... -//tensorflow/compiler/... -//tensorflow/lite/...

Several failures due to pip modules needing to be installed:

pip install scipy portpicker tensorflow-estimation

to be continued

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment