Optimized Tensorflow build for mac

Alex Egg,

Doing some research on porting a BPR recommender system in plain python to use tensorflow. However, it seems that after tensorflow v 0.5, they the stopped doing optimized mac builds and only offer a generic mac build w/o any optimizations which caused me to get lots of warnings:

2017-04-08 18:01:49.876105: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-04-08 18:01:49.876132: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-04-08 18:01:49.876140: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-04-08 18:01:49.876145: W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.

Optimized Build

Here’s how to build an optimized tensor flow install for a mac:

  1. clone the tensorflow repo
  2. ./confirgure I chose no for the GPU options
  3. bazel build -c opt --copt=-mavx --copt=-msse4.2 --copt=-msse4.1 --copt=-msse3 --copt=-mavx2 --copt=-mfma -k //tensorflow/tools/pip_package:build_pip_package
  4. bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg
  5. pip install /tmp/tensorflow_pkg/tensorflow-1.1.0rc1-cp27-none-macosx_10_10_x86_64.whl

There you go:

https://s3.amazonaws.com/eggie5_production/static/tensorflow-1.1.0rc1-cp27-none-macosx_10_10_x86_64.whl

Permalink: optimized-tensorflow-build-mac

Tags:

Last edited by Alex Egg, 2017-04-12 17:08:37
View Revision History