有没有办法抑制 TensorFlow 打印的消息?

编程入门 行业动态 更新时间:2024-10-25 06:31:00
本文介绍了有没有办法抑制 TensorFlow 打印的消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我认为这些信息在前几次确实很重要,但后来就毫无用处了.阅读和调试实际上让事情变得更糟.

I think that those messages are really important for the first few times but then it is just useless. It is actually making things worse to read and debug.

我tensorflow/stream_executor/dso_loader:128]成功打开CUDA 库 libcublas.so.8.0 本地我tensorflow/stream_executor/dso_loader:119] 无法打开 CUDA库 libcudnn.so.LD_LIBRARY_PATH:我tensorflow/stream_executor/cuda/cuda_dnn:3459] 无法加载 cuDNNDSO I tensorflow/stream_executor/dso_loader:128] 成功在本地打开 CUDA 库 libcufft.so.8.0 我tensorflow/stream_executor/dso_loader:128] 成功打开 CUDA库 libcuda.so.1 本地我tensorflow/stream_executor/dso_loader:128] 成功打开 CUDA本地库 libcurand.so.8.0

I tensorflow/stream_executor/dso_loader:128] successfully opened CUDA library libcublas.so.8.0 locally I tensorflow/stream_executor/dso_loader:119] Couldn't open CUDA library libcudnn.so. LD_LIBRARY_PATH: I tensorflow/stream_executor/cuda/cuda_dnn:3459] Unable to load cuDNN DSO I tensorflow/stream_executor/dso_loader:128] successfully opened CUDA library libcufft.so.8.0 locally I tensorflow/stream_executor/dso_loader:128] successfully opened CUDA library libcuda.so.1 locally I tensorflow/stream_executor/dso_loader:128] successfully opened CUDA library libcurand.so.8.0 locally

有没有办法压制那些只说成功的人?

Is there a way to suppress the ones that just say it was successful?

推荐答案

UPDATE(1.14 之后):请在此处查看我更彻底的回答(无论如何,这是一个欺骗性问题):https://stackoverflow/a/38645250/6557588

UPDATE (beyond 1.14): see my more thorough answer here (this is a dupe question anyway): https://stackoverflow/a/38645250/6557588

除了 Wintro 的回答,您还可以从 C 端禁用/抑制 TensorFlow 日志(即以单个字符开头的丑陋日志:I、E 等);关于日志记录的问题 已更新,声明您现在可以通过环境变量.您现在可以通过设置名为 TF_CPP_MIN_LOG_LEVEL 的环境变量来更改级别;默认为 0(显示所有日志),但可以设置为 1 以过滤掉 INFO 日志,2 以额外过滤掉 WARNING 日志,3 以额外过滤掉ERROR 日志.它现在似乎在 master 中,并且可能会成为未来版本的一部分(即 r0.11 之后的版本).请参阅此页面了解更多信息.以下是使用 Python 更改详细程度的示例:

In addition to Wintro's answer, you can also disable/suppress TensorFlow logs from the C side (i.e. the uglier ones starting with single characters: I, E, etc.); the issue open regarding logging has been updated to state that you can now control logging via an environmental variable. You can now change the level by setting the environmental variable called TF_CPP_MIN_LOG_LEVEL; it defaults to 0 (all logs shown), but can be set to 1 to filter out INFO logs, 2 to additionally filter out WARNING logs, and 3 to additionally filter out ERROR logs. It appears to be in master now, and will likely be a part of future version (i.e. versions after r0.11). See this page for more information. Here is an example of changing the verbosity using Python:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'  # or any {'0', '1', '2'}
import tensorflow as tf

您可以在运行脚本的环境中设置这个环境变量.例如,对于 bash,这可以在文件 ~/.bashrc/etc/environment/etc/profile 或在实际的 shell 中为:

You can set this environmental variable in the environment that you run your script in. For example, with bash this can be in the file ~/.bashrc, /etc/environment, /etc/profile, or in the actual shell as:

TF_CPP_MIN_LOG_LEVEL=2 python my_tf_script.py

这篇关于有没有办法抑制 TensorFlow 打印的消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

更多推荐

[db:关键词]

本文发布于:2023-05-01 05:24:56,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1405167.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:没有办法   抑制   消息   TensorFlow

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!