避免在标准错误上打印张量流 [英] Avoid tensorflow print on standard error
问题描述
有谁知道是否有一种方法可以防止 tensorflow 用 gpus 的内存分配日志污染标准错误?.我注意到当执行以下命令时:
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:
with tf.Session() as sess:
tensorflow 在标准错误上打印关于内存和 GPU 资源分配的日志.类似的东西:
tensorflow prints on standard error a log about memory and gpu resources allocation. Something like:
I tensorflow/core/common_runtime/local_device.cc:25] Local device intra op parallelism threads: 48
Graphics Device pciBusID 0000:02:00.0
Free memory: 11.75GiB
...
出于重要原因,我想避免这种打印.
For important reasons, I wanna avoid this printing.
推荐答案
此问题最近已修复,如果您升级到 TensorFlow 0.12 或更高版本,则应该可用.
This was recently fixed, and should be available if you upgrade to TensorFlow 0.12 or later.
要禁用 TensorFlow 的所有日志输出,请在启动 Python 之前设置以下环境变量:
To disable all logging output from TensorFlow, set the following environment variable before launching Python:
$ export TF_CPP_MIN_LOG_LEVEL=3
$ python ...
您还可以通过更改TF_CPP_MIN_LOG_LEVEL
的值来调整详细程度:
You can also adjust the verbosity by changing the value of TF_CPP_MIN_LOG_LEVEL
:
- 0 = 记录所有消息(默认行为)
- 1 =
INFO
消息不打印 - 2 =
INFO
和WARNING
消息不打印 - 3 =
INFO
、WARNING
和ERROR
消息不打印
- 0 = all messages are logged (default behavior)
- 1 =
INFO
messages are not printed - 2 =
INFO
andWARNING
messages are not printed - 3 =
INFO
,WARNING
, andERROR
messages are not printed
这篇关于避免在标准错误上打印张量流的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!