. Advertisement .
. Advertisement .
If the message “Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX” bothers you, you have come to the right place. Read on to remove it from your TensorFlow program.
Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX
In short, this warning appears because your system is too old and doesn’t have support for AVX/AVX2, which is required by the recent versions of TensorFlow. But what is AVX? And why does TensorFlow need it?
The answers to those questions require some knowledge about CPU instructions and the capabilities they can offer to TensorFlow users. It can be a little dry. But this understanding can help you get rid of this warning, so bear with us.
What Is AVX?
Advanced Vector Extensions (AVX) are a set of x86 instructions for some processors from Intel and AMD. Introduced in 2011, they are relatively new extensions designed to help computer CPUs deal with multiple data sets.
Intel proposed AVX in 2008 and shipped it first with the Sandy Bridge lineup in 2011. AMD came up with their own support for these instructions in the same year with the Bulldozer processors. AVX2 and AVX-512 are two enhanced versions of AVX, adding 256-bit and 521-bit support.
AVX doesn’t just require specific hardware but also needs support from the operating system. Most major platforms have added support for AVX, including Windows since the Windows 7 SP1 version.
TensorFlow And AVX
AVX enables many operations, including FMA (fused multiply-accumulate). It can accelerate matrix multiply, namely dot-product, and linear algebra computation.
As you may know, training with machine learning typically requires a great deal of those operations. If you train on a CPU, AVX and FMA can reduce the training time tremendously. They provide specialized vector instructions that make large data processing a breeze.
That is why TensorFlow has added support for AVX by default since the 1.6 version. The official binaries you download from TensorFlow’s websites already include it.
However, many legacy systems will run into a problem with those binaries. Older CPUs don’t have AVX in their architecture, and every official installation method will result in the “Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX” warning.
How To Remove The Warning
If your program doesn’t require AVX instructions, you can just straight up ignore the message. It is especially true when you plan to use your GPU for your machine learning tasks. You don’t need to care about AVX support in this case, which only concerns the CPU.
You can also change the way TensorFlow logs to prevent it from printing this message. The environment variable TF_CPP_MIN_LOG_LEVEL controls the logging level, which can be easily changed by the os module:
>>> import os >>> os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
Level 2 logging means TensorFlow prints all messages except for debugging information. You can also switch to levels 3, 4, or 5, which all ignore support for AVX. Learn more about them here.
Build TensorFlow From Source
Since TensorFlow is open-source software, you are free to compile it in any way you want. This process allows you to remove AVX support altogether, meaning it won’t print any warning in your old system. Be aware: this is super complicated and not intended for everyone.
Download Pre-Built Binaries
Some developers build their own TensorFlow binaries without AVX and share them on the Internet. One popular build is tensorflow-windows-wheel, which ensures support for legacy CPUs. Remember to remove the existing version first:
$ pip remove tensorflow
AVX is an advanced instruction set that allows for many operations on large data streams. However, if you have an old CPU, you may end up with the “Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX” warning. You can ignore it or choose a different binary built without AVX.