CPU instructions not compiled with TensorFlow

21,729

Solution 1

NOTE : These are not error messages but mere warning messages.

The best way to maximise TF performance (apart from writing good code !!), is to compile it from the sources

When you do that, TF would ask you for a variety of options which will also involve options for these instructions.

In my own experience, compilation from the source is better in performance on an average.

If you are doing some intensive processing that could be done on a GPU then that might also explain your waiting time. For GPU support you would need to do pip3 install tensorflow-gpu

Solution 2

You can also compile using bazel with opt arguments:

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

I think you can find something in this discussion: How to compile Tensorflow with SSE4.2 and AVX instructions?

Good luck!

Share:
21,729
Fizics
Author by

Fizics

Updated on August 23, 2020

Comments

  • Fizics
    Fizics over 3 years

    MacBook Air: OSX El Capitan

    When I run TensorFlow code in terminal (python 3 tfpractice.py), I get a longer than normal waiting time to get back output followed by these error messages:

    W tensorflow/core/platform/cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations. 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. 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. 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. 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.

    I have no clue how to fix this. I would like to get TensorFlow to just work on this pip3 install. So I followed the path to: tensorflow/core/platform/cpu_feature_guard

    Do I need to edit the code here? Or is there an alternate way to get TensorFlow to compile with these instructions?

    I installed TensorFlow using sudo pip3 install tensorflow.

  • Fizics
    Fizics about 7 years
    Thank you. I will try your suggestion and give an update
  • Peter Cordes
    Peter Cordes over 6 years
    That doesn't make it run faster, it just silences the warnings.
  • RedEyed
    RedEyed over 6 years
    I would suggest to use bazel build -c opt --copt=-march=native //tensorflow/tools/pip_package:build_pip_package. The -march=native will chose all supported CPU features at current machine. To see CPU features gcc -march=native -Q --help=target | grep enabled