Avoid tensorflow print on standard error

前端 未结 3 1317
温柔的废话
温柔的废话 2020-12-16 05:18

anyone knows if there is a method to prevent tensorflow from polluting standard error with gpus\' memory allocation log?. I noted that when the following command is executed

相关标签:
3条回答
  • 2020-12-16 05:31

    You can set an environment variable before launching Python as described in the first answer, or you can add the following lines to your Python code:

    import os  
    os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'  
    

    Change 3 to values (0, 1, 2, 3) according to the messages you want avaoid.

    PS: If you're using TensorFlow => 2.0, make sure to put those lines before importing tensorflow to be effective.

    0 讨论(0)
  • 2020-12-16 05:46

    This was recently fixed, and should be available if you upgrade to TensorFlow 0.12 or later.

    To disable all logging output from TensorFlow, set the following environment variable before launching Python:

    $ export TF_CPP_MIN_LOG_LEVEL=3
    $ python ...
    

    You can also adjust the verbosity by changing the value of TF_CPP_MIN_LOG_LEVEL:

    • 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
    0 讨论(0)
  • 2020-12-16 05:50

    Defaults to 0, so all logs are shown. Set TF_CPP_MIN_LOG_LEVEL to 1 to filter out INFO logs, 2 to additionall filter out WARNING, 3 to additionally filter out ERROR.

    0 讨论(0)
提交回复
热议问题