Home > Backend Development > Python Tutorial > How to Silence TensorFlow Debugging Messages?

How to Silence TensorFlow Debugging Messages?

Linda Hamilton
Release: 2024-11-01 13:05:29
Original
766 people have browsed it

How to Silence TensorFlow Debugging Messages?

How to Suppress TensorFlow Debugging Information

TensorFlow users may encounter extraneous console messages regarding loaded libraries and available devices. These messages can be intrusive, especially in production environments or when debugging Python code.

Solution: Disable Debugging Information

To disable this debugging information, set the TF_CPP_MIN_LOG_LEVEL environment variable:

<code class="python">import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tensorflow as tf</code>
Copy after login

Explanation:

The TF_CPP_MIN_LOG_LEVEL environment variable controls the minimum severity level of messages that are printed. By setting it to '3', all messages with severity level less than 3 (i.e., INFO, WARNING, and ERROR) are suppressed.

Log Level Hierarchy:

  • 0: All messages are printed (default behavior)
  • 1: INFO messages are not printed
  • 2: INFO and WARNING messages are not printed
  • 3: INFO, WARNING, and ERROR messages are not printed

This solution has been tested and confirmed to work with TensorFlow versions 0.12 and 1.0.

The above is the detailed content of How to Silence TensorFlow Debugging Messages?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template