Removing TensorFlow Warning Messages

On Revisiting TensorFlow™ I mentioned an issue with warning messages regarding SSE instructions. I understand the reason but would like to get rid of them. They clobber the output making it difficult to follow what the program is doing.

Following is a modified Python program from a Google tutorial:

import tensorflow as tf

# **** create two constant nodes ****

node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly

# **** print the nodes ****

print(node1, node2)
#print(node1)
#print(node2)

# **** create a session and evaluate the nodes ****

sess = tf.Session()
print(sess.run([node1, node2]))

The output from the program follows:

Tensor("Const:0", shape=(), dtype=float32) Tensor("Const_1:0", shape=(), dtype=float32)
2017-05-23 09:09:10.576648: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The Te
nsorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-05-23 09:09:10.576905: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The Te
nsorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-23 09:09:10.577223: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The Te
nsorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-23 09:09:10.577535: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The Te
nsorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-23 09:09:10.577849: W c:\tf_jenkins\home\workspace\release-win\device\cpu\os\windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The Te
nsorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
[3.0, 4.0]

As you can tell, the warnings get on the way.

Following is a modified program:

import os
import tensorflow as tf

# **** change the warning level ****

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'

# **** create two constant nodes ****

node1 = tf.constant(3.0, tf.float32)
node2 = tf.constant(4.0) # also tf.float32 implicitly

# **** print the nodes ****

print(node1, node2)
#print(node1)
#print(node2)

# **** create a session and evaluate the nodes ****

sess = tf.Session()
print(sess.run([node1, node2]))

The output of the modified program follows:

Tensor("Const:0", shape=(), dtype=float32) Tensor("Const_1:0", shape=(), dtype=float32)
[3.0, 4.0]

All the clutter from the warning messages is gone. By the way, I am writing Python code using Notepad++ giving the files the extension “.py”. I am using a Windows machine. So far; so good.

As usual, if you have comments or questions regarding this or any other post, please leave me your comments in the area provided after this post.

Enjoy;

John

Follow me on Twitter:  @john_canessa

Leave a Reply

Your email address will not be published. Required fields are marked *