Fix: Your CPU Supports Instructions that this TensorFlow Binary was not Compiled to use AVX2

Advanced Vector Extensions (AVX, also known as Sandy Bridge New Extensions) are extensions to the x86 instruction set architecture for microprocessors from Intel and AMD proposed by Intel in March 2008 and first supported by Intel with the Sandy Bridge processor shipping in Q1 2011 and later on by AMD with the Bulldozer processor shipping in Q3 2011. AVX provides new features, new instructions, and a new coding scheme.

This warning message is printed by the shared library of TensorFlow. As the message indicates, the shared library doesn’t include the kind of instructions that your CPU could use.

What Causes this Warning?

After TensorFlow 1.6, the binaries now use AVX instructions which may not run on older CPUs anymore. So the older CPUs will be unable to run the AVX, while for the newer ones, the user needs to build the tensorflow from source for their CPU. Below is all the information you need to know about this particular warning. Also, a method about getting rid of this warning for future use.

What does the AVX do?

In particular, the AVX introduced the FMA (Fused multiply-add); which is the floating-point multiply-add operation, and this all operation is done in a single step. This helps speed up many operations without any problem. It makes the algebra computation more fast and easy use, also the dot-product, matrix multiply, convolution, etc. And these are all the most used and basic operations for every machine-learning training. The CPUs that support the AVX and FMA will be far faster than the older ones. But the warning states that your CPU supports AVX, so it’s a good point.

Why it isn’t used by default?

That is because the TensorFlow default distribution is built without the CPU extensions. By CPU extensions it states the AVX, AVX2, FMA, etc. The instructions which trigger this issue are not enabled by default on the available default builds. The reasons they are not enabled is to make this more compatible with as many CPUs as possible. Also to compare these extensions, they are a lot slower in CPU rather than GPU. CPU is used on the small-scale machine-learning while the use of GPU is expected when it is used for a medium or large-scale machine-learning training.

Fixing the Warning!

These warnings are just simple messages. The purpose of these warnings is to inform you about the built TensorFlow from source. When you build the TensorFlow from the source it can be faster on the machine. So all these warnings are telling you about is the build up TensorFlow from source.

If you have a GPU on your machine, then you can ignore these warnings from AVX support. Because most expensive ones will be dispatched on a GPU device. And if you want to not see this error anymore, you can just simply ignore it by adding this:

import the OS module in your main program code and also set the mapping object for it

# For disabling the warningimport osos.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

But if you are on a Unix, then use the export command in bash shell

export TF_CPP_MIN_LOG_LEVEL=2

But if don’t have GPU, and you want to use your CPU as much as possible, you should build TensorFlow from the source optimized for your CPU with AVX, AVX2, and FMA enabled here.