导入torch.utils.tensorboard引发tensorflow警告
正如这里所说,tensorboard是tensorflow的一部分,但并不依赖于它。你可以在pytorch中使用它,比如这样:
from torch.utils.tensorboard import SummaryWriter
不过,这个导入会导致出现很多和tensorflow相关的警告信息,真让人烦。
2024-03-28 12:11:43.296359: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2024-03-28 12:11:43.331928: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-03-28 12:11:43.970865: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
我在想,这些警告信息是否真的有必要,或者有没有办法(安全地)把它们静音。
2 个回答
0
如果这些警告不会影响你的代码运行或性能,你可以选择忽略它们。
import warnings
warnings.filterwarnings("ignore", category=FutureWarning)
0
我找到了一种解决办法,不需要导入tensorflow(我并不使用它),但可以通过环境变量来静音的方法:
只需在你的脚本开头添加这一行。
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' # FATAL
这个方法适用于任何版本的 tensorflow > 1.14