禁用 TensorFlow 警告和消息

disable tensorflow warnings and messages

提问人:brownie 提问时间:10/26/2022 最后编辑:brownie 更新时间:10/26/2022 访问量:2208

问:

我正在使用 tensorflow==2.10.0,并且一直在尝试删除每次运行 python 脚本时弹出的这些消息。我没有 Nvidia GPU。

2022-10-26 13:58:46.926429: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2 AVX_VNNI FMA
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2022-10-26 13:58:47.010141: I tensorflow/core/util/util.cc:169] 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`.
2022-10-26 13:58:47.013778: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.so.11.0'; dlerror: libcudart.so.11.0: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/vojta/anaconda3/envs/newest/lib/python3.10/site-packages/cv2/../../lib64:
2022-10-26 13:58:47.013793: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
2022-10-26 13:58:47.031358: E tensorflow/stream_executor/cuda/cuda_blas.cc:2981] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered
2022-10-26 13:58:47.371213: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer.so.7'; dlerror: libnvinfer.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/vojta/anaconda3/envs/newest/lib/python3.10/site-packages/cv2/../../lib64:
2022-10-26 13:58:47.371255: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libnvinfer_plugin.so.7'; dlerror: libnvinfer_plugin.so.7: cannot open shared object file: No such file or directory; LD_LIBRARY_PATH: /home/vojta/anaconda3/envs/newest/lib/python3.10/site-packages/cv2/../../lib64:
2022-10-26 13:58:47.371259: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Cannot dlopen some TensorRT libraries. If you would like to use Nvidia GPU with TensorRT, please make sure the missing libraries mentioned above are installed properly.

我用谷歌搜索并尝试了所有这些,但没有任何区别

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'
tf.get_logger().setLevel('INFO') 
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)

唯一几乎完美的是这个(在终端内)

TF_CPP_MIN_LOG_LEVEL=2 time python main.py

但是,一开始仍然有一条消息

2022-10-26 13:58:26.477557: E tensorflow/stream_executor/cuda/cuda_blas.cc:2981] Unable to register cuBLAS factory: Attempting to register factory for plugin cuBLAS when one has already been registered

每次我做 model.save() 时都会收到 2 条消息

WARNING:absl:Found untraced functions such as _jit_compiled_convolution_op, _jit_compiled_convolution_op, _jit_compiled_convolution_op while saving (showing 3 of 3). These functions will not be directly callable after loading.
WARNING:absl:Found untraced functions such as _jit_compiled_convolution_op, _jit_compiled_convolution_op, _jit_compiled_convolution_op while saving (showing 3 of 3). These functions will not be directly callable after loading.

我希望能够解决,而不必在每次我想运行脚本时都编写额外的内容。

关于如何摆脱消息的任何想法?为什么在终端工作但没有结束?TF_CPP_MIN_LOG_LEVEL=2os.environ

感谢您的帮助

Python C++ TensorFlow 深度学习 警告

评论

0赞 furas 10/26/2022
如果你没有GPU,那么也许你应该安装CPU的版本,或者你应该从源代码编译自己的版本。您还可以在 github.com/yaroslavvb/tensorflow-community-wheels/issues 上检查预编译版本
0赞 furas 10/27/2022
您在导入之前使用过吗?os.environtensorflow
0赞 brownie 10/27/2022
导入tensorflow后,我使用了os.environ
0赞 furas 10/27/2022
您可以在导入之前尝试使用,因为它可能会在导入过程中获取值。os.environtensorflowos.environ
0赞 brownie 11/2/2022
尝试过但没有奏效

答: 暂无答案