tensorflow: TF_CPP_MIN_LOG_LEVEL does not work with TF2.0 dev20190820
System information
- Have I written custom code (as opposed to using a stock example script provided in TensorFlow): yes
- OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Windows 10 x64 1903
- Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device:
- TensorFlow installed from (source or binary): pip
- TensorFlow version (use command below): 2.0.0-dev20190820
- Python version: 3.6.7
- Bazel version (if compiling from source):
- GCC/Compiler version (if compiling from source):
- CUDA/cuDNN version: CUDA 10, cuDNN 7.6.2.24
- GPU model and memory: Geforce RTX 2080 ti 11GB
Describe the current behavior Setting TF_CPP_MIN_LOG_LEVEL does not work lateset TF 2.0. If I set TF_CPP_MIN_LOG_LEVEL to 2, sill TF shows information and warning logs (including libpng warnings)
With dev20190504, this issue does not occurred.
Describe the expected behavior Set TF_CPP_MIN_LOG_LEVEL=2 should prevent showing information/warning logs including libpng warnings.
Code to reproduce the issue
import os
import tensorflow as tf
import numpy as np
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
a = tf.Variable(np.array([0, 1, 2]))
print(a)
You can see many [I] log using dev20190820. But with dev20190504, no logs.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 34 (5 by maintainers)
After a quick dig into this, it seems that the problem appear only if you change the log level after import tensorflow.
output:
if i change set the environ after import tf:
output:
This happens in Tensorflow 2.0rc, however Tensorflow beta0&beta1 works good no matter the order of import.
Maybe in the latest code change the logger reading the TF_CPP_MIN_LOG_LEVEL once when init, and in the older version, the logger was reading TF_CPP_MIN_LOG_LEVEL on the fly. Could you please confirm if this is intend to do or a bug introduced in the latest version? @gadagashwini
@bersbersbers I think its not the same issue, tf.get_logger().setLevel(‘ERROR’) means set your python tensorflow log level to “ERROR”, and the evn value “TF_CPP_MIN_LOG_LEVEL” is to set tensorflow c++ log level. So in my code, i usually set them both like this:
@akhil189 It seems not fixed yet. Temporary workaround is that call
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "2"
beforeimport tensorflow as tf
, or manually set environment variable TF_CPP_MIN_LOG_LEVEL=2 before running your python script.@KichangKim Thank you for providing the workaround. But, I am using google colab and it’s not working in that. The ‘INFO’ and ‘WARNING’ messages are still being shown in the output.
This issue seem to be still open, but with workaround mentioned by @KichangKim works fine. Version :
2.3.0
Sample for verification
I know this is not an ideal env. I am using cygwin, on top of that I am calling a python binary installed for windows. Anyways, I think it does prove that the workaround for logging works.
@bersbersbers Oh, I misread ziyigogogo’s comment. It seems that not yet concluded. Reopen.
This is fixed in tf-2.0 nightly build version 2.0.0-dev20190826 in the sense we see:
output: