Cpu supports instructions that this tensorflow binary was not compiled to use: avx2 fma

When I was working on my new tensorflow project, I got the warning that CPU supports instructions that this tensorflow binary was not compiled to use: avx2, fma. This shows that our CPU can speed up the tensorflow execution but our package is not utilizing it. This is actually a good thing.

Consider this code –

import tensorflow as tf
sess = tf.Session()
a = tf.constant(10)
b = tf.constant(20)
sess.run(a + b)
sess.close()

While running this code, I got the warning. Since some computations are involved, tensorflow looked for the opportunity to increase the speed and performance.

What is this warning?

Processor designing companies like Intel and AMD do a continuous research on technology. CPU performs multiple tasks and ALU operations are primary among them. Some of these architectures are optimized for machine learning calculations like scalar multiplication, cross product, dot product, matrix transpose etc. These are AVX and AVX2 (Wikipedia).

If your CPU is one of those architectures which can support AVX and AVX2, then you will get tensorflow warning.

Why tensorflow warns?

Tensorflow library is designed to keep the requirements of majority of machines. To make it compatible, the optimizations related to particular CPU variants are turned off in public distribution. To use this feature, developer needs to build the source best compatible for their architecture.

Computers with GPU

GPU are more preferable than CPU when it comes to high computation. So, if you have GPU in your system then you should not worry about the warning. When there is need, tensorflow will automatically starts using GPU instead of CPU.

Suppress Warning

To suppress this warning, you can use this command –

a. For windows

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

b. For UNIX

export TF_CPP_MIN_LOG_LEVEL=2

    Tweet this to help others