Python – Tensorflow on MacOS: Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA


I tried to validate my tensorflow for my mac using these instructions

but produce this result. is that ok? bad? how can i fix this? thanks

  • sess = tf.Session()

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA

  • print(

b'Hello, TensorFlow!'

Mac OS version: MacOS High Sierra 10.13.6

here is the full installation and validation output:

usermacbook:tensorflowve someuser$ python3 -m venv . 
usermacbook:tensorflowve someuser$ source bin/activate
(tensorflowve) usermacbook:tensorflowve someuser$ pip3 install --upgrade tensorflow
Collecting tensorflow
  Downloading (48.9MB)
    100% |████████████████████████████████| 48.9MB 30kB/s 
Collecting termcolor>=1.1.0 (from tensorflow)
Collecting protobuf>=3.4.0 (from tensorflow)
  Downloading (1.2MB)
    100% |████████████████████████████████| 1.2MB 986kB/s 
Collecting absl-py>=0.1.6 (from tensorflow)
  Downloading (84kB)
    100% |████████████████████████████████| 92kB 3.7MB/s 
Collecting gast>=0.2.0 (from tensorflow)
Collecting grpcio>=1.8.6 (from tensorflow)
  Downloading (1.9MB)
    100% |████████████████████████████████| 1.9MB 654kB/s 
Collecting tensorboard<1.10.0,>=1.9.0 (from tensorflow)
  Downloading (3.3MB)
    100% |████████████████████████████████| 3.3MB 425kB/s 
Collecting numpy>=1.13.3 (from tensorflow)
  Downloading (24.5MB)
    100% |████████████████████████████████| 24.5MB 59kB/s 
Collecting setuptools<=39.1.0 (from tensorflow)
  Downloading (566kB)
    100% |████████████████████████████████| 573kB 1.6MB/s 
Collecting six>=1.10.0 (from tensorflow)
Collecting astor>=0.6.0 (from tensorflow)
Collecting wheel>=0.26 (from tensorflow)
  Downloading (41kB)
    100% |████████████████████████████████| 51kB 4.0MB/s 
Collecting werkzeug>=0.11.10 (from tensorboard<1.10.0,>=1.9.0->tensorflow)
  Downloading (322kB)
    100% |████████████████████████████████| 327kB 2.0MB/s 
Collecting markdown>=2.6.8 (from tensorboard<1.10.0,>=1.9.0->tensorflow)
  Downloading (78kB)
    100% |████████████████████████████████| 81kB 3.7MB/s 
Installing collected packages: termcolor, setuptools, six, protobuf, absl-py, gast, grpcio, numpy, werkzeug, markdown, wheel, tensorboard, astor, tensorflow
  Running install for termcolor ... done
  Found existing installation: setuptools 28.8.0
    Uninstalling setuptools-28.8.0:
      Successfully uninstalled setuptools-28.8.0
  Running install for absl-py ... done
  Running install for gast ... done
Successfully installed absl-py-0.3.0 astor-0.7.1 gast-0.2.0 grpcio-1.14.0 markdown-2.6.11 numpy-1.15.0 protobuf-3.6.0 setuptools-39.1.0 six-1.11.0 tensorboard-1.9.0 tensorflow-1.9.0 termcolor-1.1.0 werkzeug-0.14.1 wheel-0.31.1
You are using pip version 9.0.1, however version 18.0 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
(tensorflowve) usermacbook:tensorflowve someuser$ python
Python 3.6.3 (v3.6.3:2c5fed86e0, Oct  3 2017, 00:32:08) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> hello = tf.constant('Hello, TensorFlow!')
>>> sess = tf.Session()
2018-08-04 09:28:35.905544: I tensorflow/core/platform/] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA
>>> print(
b'Hello, TensorFlow!'

Best Solution

Tensorflow compiled with the advanced instructions can run 40% faster than the non-optimised code, so please don't ignore this message!

I would recommend building TF from source, here are the steps to download, compile and install v2.0 beta, including the link to the compiled .whl file.

First, uninstall the default version:

sudo pip3 uninstall protobuf
sudo pip3 uninstall tensorflow

In a temp folder, clone Tensorflow:

git clone 
git checkout r2.0

Install the TensorFlow pip package dependencies:

pip3 install -U --user pip six numpy wheel setuptools mock future>=0.17.1
pip3 install -U --user keras_applications==1.0.6 --no-deps
pip3 install -U --user keras_preprocessing==1.0.5 --no-deps

Install Bazel, the build tool used to compile TensorFlow. After downloading

chmod +x ./ --user export PATH="$PATH:$HOME/bin" bazel version

Configure your system build by running the following at the root of your TensorFlow source tree:


Use bazel to make the TensorFlow package builder with CPU-only support:

bazel build -c opt --copt=-mavx --copt=-mavx2 --copt=-mfma --copt=-msse4.2 //tensorflow/tools/pip_package:build_pip_package

The bazel build command creates an executable named build_pip_package—this is the program that builds the pip package. Run the executable as shown below to build a .whl package in the /tmp/tensorflow_pkg directory.

To build from a release branch:

./bazel-bin/tensorflow/tools/pip_package/build_pip_package /tmp/tensorflow_pkg

The output wheel file is in: /tmp/tensorflow_pkg. You may download the file from here, and try to install it directly

pip3 install /tmp/tensorflow_pkg/tensorflow-2.0.0b1-cp37-cp37m-macosx_10_14_x86_64.whl 

cd out of that directory, and now running this should not produce any warning:

python3 -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

The original post was published here.

Related Question