QBoard » Artificial Intelligence & ML » AI and ML - Tensorflow » Disable Tensorflow debugging information

Disable Tensorflow debugging information

  • By debugging information I mean what TensorFlow shows in my terminal about loaded libraries and found devices etc. not Python errors.

    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcublas.so locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcudnn.so locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcufft.so locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcuda.so.1 locally
    I tensorflow/stream_executor/dso_loader.cc:105] successfully opened CUDA library libcurand.so locally
    I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:900] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero
    I tensorflow/core/common_runtime/gpu/gpu_init.cc:102] Found device 0 with properties: 
    name: Graphics Device
    major: 5 minor: 2 memoryClockRate (GHz) 1.0885
    pciBusID 0000:04:00.0
    Total memory: 12.00GiB
    Free memory: 11.83GiB
    I tensorflow/core/common_runtime/gpu/gpu_init.cc:126] DMA: 0 
    I tensorflow/core/common_runtime/gpu/gpu_init.cc:136] 0:   Y 
    I tensorflow/core/common_runtime/gpu/gpu_device.cc:717] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Graphics Device, pci bus id: 0000:04:00.0)
    I tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:51] Creating bin of max chunk size 1.0KiB
    ...
      September 21, 2021 12:31 AM IST
    0
  • You can disable all debugging logs using os.environ :
    import os os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' import tensorflow as tf
    Tested on tf 0.12 and 1.0
    In details,
    0 = all messages are logged (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
      September 21, 2021 6:53 PM IST
    0
  • I have had this problem as well (on tensorflow-0.10.0rc0), but could not fix the excessive nose tests logging problem via the suggested answers.

    I managed to solve this by probing directly into the tensorflow logger. Not the most correct of fixes, but works great and only pollutes the test files which directly or indirectly import tensorflow:

    # Place this before directly or indirectly importing tensorflow
    import logging
    logging.getLogger("tensorflow").setLevel(logging.WARNING)​
      September 27, 2021 2:08 PM IST
    0
  • For compatibility with Tensorflow 2.0, you can use tf.get_logger
    import logging tf.get_logger().setLevel(logging.ERROR)
      September 27, 2021 5:02 PM IST
    0
  • I am using Tensorflow version 2.3.1 and none of the solutions above have been fully effective.
    Until, I find this package.

    Install like this:

    with Anaconda,

    python -m pip install silence-tensorflow
    

     

    with IDEs,

    pip install silence-tensorflow
    

     

    And add to the first line of code:

    from silence_tensorflow import silence_tensorflow
    silence_tensorflow()
      September 28, 2021 1:54 PM IST
    0