"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Suppress Tensorflow Debugging Output?

How to Suppress Tensorflow Debugging Output?

Published on 2024-11-06
Browse:301

How to Suppress Tensorflow Debugging Output?

Suppressing Tensorflow Debugging Information

Tensorflow may display debugging information in the terminal upon initialization, including loaded libraries and discovered devices. While this information can be useful for debugging purposes, it can also clutter the console and make it difficult to track important messages.

To disable this debugging information, you can utilize the os.environ module:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' 
import tensorflow as tf

This code sets the minimum logging level for Tensorflow to 3, effectively suppressing all debugging information.

The logging levels in Tensorflow range from 0 to 3, with 0 indicating all messages are printed and 3 indicating that only error messages are printed. Here's a breakdown of the logging levels:

  • 0: All messages are logged.
  • 1: INFO messages are not printed.
  • 2: INFO and WARNING messages are not printed.
  • 3: INFO, WARNING, and ERROR messages are not printed.

Setting the minimum logging level to 3 ensures that no debugging information is displayed, regardless of the version of Tensorflow being used (tested with versions 0.12 and 1.0). This approach provides a clean and concise console output, allowing you to focus on essential messages.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3