2

How can I turn off tensorflow messages such as :

2019-08-14 16:07:26.928502: I tensorflow/core/common_runtime/placer.cc:54] Adam_3/decay/initial_value: (Const)/job:localhost/replica:0/task:0/device:CPU:0

2019-08-14 16:07:26.928520: I tensorflow/core/common_runtime/placer.cc:54] noisy_layer_4_target: (Placeholder)/job:localhost/replica:0/task:0/device:CPU:0
....

I've tried :

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
os.environ['TF_CPP_MIN_VLOG_LEVEL'] = '3'
tf.logging.set_verbosity(tf.logging.ERROR) # also tried  DEBUG, FATAL, WARN, INFO
logging.getLogger('tensorflow').disabled = True

from other SO questions but they don't change anything.

I'm using keras with tf as backend , with tf.version = 1.14, in spyder

Makis Kans
  • 337
  • 3
  • 12

3 Answers3

1

See this answer.

Setting tf.logging.set_verbosity to ERROR does not always completely block all INFO logs.

In Linux, you can try below.

If you are using Linux, you can just grep out all output strings beginning with I tensorflow/

Example:

$ python main.py | grep -v "unwanted_word"
Sihyeon Kim
  • 161
  • 7
  • 1
    Hi Kim, thanks for the answer. Can I use grep from inside spyder to filter the output of my script? Googling doesn't give me an answer – Makis Kans Aug 14 '19 at 14:41
  • I get: "AttributeError: module 'tensorflow' has no attribute 'logging' " any ideas ? Thanks in advance! – LC117 Jul 08 '21 at 16:07
0

append to lines above tf_logging

tf.logging.set_verbosity(tf.logging.ERROR)  # or any {DEBUG, INFO, WARN, ERROR, FATAL}
Jayjay
  • 112
  • 1
  • 1
  • 9
0
import logging, os 
logging.disable(logging.WARNING) 
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"
mlneural03
  • 833
  • 1
  • 8
  • 11