Tf cpp min log level

Turning off the annoying stdout messages from TensorFlow 2.0rc

When writing the TensorFlow code in Python scripts and running the scripts in a terminal, we usually get a bunch of messages in stdout. The messages log the information of the initialization stage of TensorFlow. These messages are annoying to many people. The messages come from both the underlying C++ code and the Python code of TensorFlow. So we need to disable the two sources of the messages in different ways.

If we install TensorFlow through conda or pip , then the C++ code is already compiled, and we don’t have any way to modify the C++ source code. Fortunately, the messages coming from this source can be controlled by an environment variable, TF_CPP_MIN_LOG_LEVEL . In Linux, before running Python scripts, we can simply do something like $ export TF_CPP_MIN_LOG_LEVEL=2 . But I prefer to hard code this environment variable in my Python scripts because I’m lazy. I add the following code in my Python scripts before the code uses any TensorFlow object or function:

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

This code does not necessarily need to be placed before import tensorflow . But it must be placed before the code encounters any object or function coming from TensorFlow. I think the initialization of the TensorFlow package does not happen before this point.

The second source of the messages can be turned off by the standard Python logging system:

 import logging logging.getLogger("tensorflow").setLevel(logging.ERROR) logging.getLogger("tensorflow").addHandler(logging.NullHandler(logging.ERROR)) 

6 Comments

os.environ[“TF_CPP_MIN_LOG_LEVEL”] = 2 produces an error: “expecting str, not int”. So the way it works for me is: os.environ[“TF_CPP_MIN_LOG_LEVEL”] = “2”

I tried so many things including your advice … but still it’s not suppressed.
I don’t know what to do… it’s really annoying and quite tilting. My setting
python 3.7
tensorflow version: 2.1.0
Spyder 4.1.4 Do you know what I could do? Greetings,
Ilkay

Читайте также:  Java jar file netbeans

2020-09-02 09:21:41.007603: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-09-02 09:21:42.774448: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll
2020-09-02 09:21:42.795887: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce RTX 2080 computeCapability: 7.5
coreClock: 1.71GHz coreCount: 46 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.23GiB/s
2020-09-02 09:21:42.797785: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-09-02 09:21:42.803610: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-09-02 09:21:42.807019: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-09-02 09:21:42.808226: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-09-02 09:21:42.812423: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-09-02 09:21:42.814652: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-09-02 09:21:42.822271: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-09-02 09:21:42.822677: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2020-09-02 09:21:42.845317: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
2020-09-02 09:21:42.846307: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1555] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce RTX 2080 computeCapability: 7.5
coreClock: 1.71GHz coreCount: 46 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.23GiB/s
2020-09-02 09:21:42.846995: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_101.dll
2020-09-02 09:21:42.847343: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_10.dll
2020-09-02 09:21:42.847687: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_10.dll
2020-09-02 09:21:42.848035: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_10.dll
2020-09-02 09:21:42.848380: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_10.dll
2020-09-02 09:21:42.848729: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_10.dll
2020-09-02 09:21:42.849085: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll
2020-09-02 09:21:42.849455: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1697] Adding visible gpu devices: 0
2020-09-02 09:21:43.362098: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1096] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-09-02 09:21:43.362477: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1102] 0
2020-09-02 09:21:43.362702: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1115] 0: N
2020-09-02 09:21:43.363078: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1241] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6269 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2080, pci bus id: 0000:01:00.0, compute capability: 7.5)

I upgraded my TF to version 2.3 and found that some behaviors have been changed. Now I have to put these lines of code completely before import tensorflow (or any lines importing modules from tensorflow). Have you tried to put these lines at the very beginning of your source files? At least it worked for me on Linux.

Читайте также:  Var to str php

Leave a Reply Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Источник

Saved searches

Use saved searches to filter your results more quickly

You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session. You switched accounts on another tab or window. Reload to refresh your session.

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TF_CPP_MIN_LOG_LEVEL does not work with TF2.0 dev20190820 #31870

TF_CPP_MIN_LOG_LEVEL does not work with TF2.0 dev20190820 #31870

comp:runtime c++ runtime, performance issues (cpu) TF 2.0 Issues relating to TensorFlow 2.0 type:bug Bug

Comments

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.

Читайте также:  Javascript class this that

The text was updated successfully, but these errors were encountered:

gadagashwini-zz added the stat:awaiting response Status — Awaiting response from author label Aug 22, 2019

@gadagashwini Thanks for testing. But gist’s result differ to my local result.
Here is my output:

2019-08-22 20:52:13.256379: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll 2019-08-22 20:52:19.121304: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll 2019-08-22 20:52:19.391093: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties: name: GeForce RTX 2080 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.755 pciBusID: 0000:06:00.0 2019-08-22 20:52:19.398066: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll 2019-08-22 20:52:19.410017: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_100.dll 2019-08-22 20:52:19.419415: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_100.dll 2019-08-22 20:52:19.426158: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_100.dll 2019-08-22 20:52:19.450504: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_100.dll 2019-08-22 20:52:19.501850: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_100.dll 2019-08-22 20:52:19.545794: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll 2019-08-22 20:52:19.551803: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0 2019-08-22 20:52:19.555811: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2019-08-22 20:52:19.564630: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties: name: GeForce RTX 2080 Ti major: 7 minor: 5 memoryClockRate(GHz): 1.755 pciBusID: 0000:06:00.0 2019-08-22 20:52:19.569926: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll 2019-08-22 20:52:19.573802: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cublas64_100.dll 2019-08-22 20:52:19.578127: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cufft64_100.dll 2019-08-22 20:52:19.582843: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library curand64_100.dll 2019-08-22 20:52:19.593490: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusolver64_100.dll 2019-08-22 20:52:19.598530: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cusparse64_100.dll 2019-08-22 20:52:19.604157: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudnn64_7.dll 2019-08-22 20:52:19.610050: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0 2019-08-22 20:52:21.725773: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect StreamExecutor with strength 1 edge matrix: 2019-08-22 20:52:21.735777: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165] 0 2019-08-22 20:52:21.738297: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N 2019-08-22 20:52:21.742246: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8686 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2080 Ti, pci bus id: 0000:06:00.0, compute capability: 7.5) PS C:\Users\kicha\Downloads\tensorflow-issue> 

Can you try my code on local machine?

Источник

Оцените статью