gpt4 book ai didi

python - 停止 Tensorflow 打印到控制台

转载 作者:行者123 更新时间:2023-12-04 13:11:44 24 4
gpt4 key购买 nike

我一直在用tensorflow没有问题,直到我添加了以下代码行:

log_dir = os.path.join("logs",
"fit",
datetime.datetime.now().strftime("%Y%m%d-%H%M%S"))

tensorboard_callback = TensorBoard(log_dir)
运行此程序后,我将大量信息打印到控制台。我试过查看 tf.keras.callbacks.TensorBoard documentation看看我是否可以减少冗长,但我没有看到一个选项。
来自各种 stackoverflow answers我也试过设置 tf 的详细程度下来但无济于事:
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
tf.get_logger().setLevel('ERROR')
tf.autograph.set_verbosity(3)
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
我有以下规范:
Python = 3.8
Tensorflow = 2.3.1
Cuda Toolkit = 10.1
cuDNN = 7.6.4
GPU=Nvidia RTX2060
控制台打印的信息都是 I消息,如果它们添加了任何重要的细节,我已将它们粘贴在下面。
2020-10-19 20:59:45.205887: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
2020-10-19 20:59:47.463539: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library nvcuda.dll
2020-10-19 20:59:48.540417: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce RTX 2060 computeCapability: 7.5
coreClock: 1.2GHz coreCount: 30 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 312.97GiB/s
2020-10-19 20:59:48.542360: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
2020-10-19 20:59:48.562444: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cublas64_10.dll
2020-10-19 20:59:48.569770: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cufft64_10.dll
2020-10-19 20:59:48.572530: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library curand64_10.dll
2020-10-19 20:59:48.581126: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusolver64_10.dll
2020-10-19 20:59:48.586315: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusparse64_10.dll
2020-10-19 20:59:48.604682: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudnn64_7.dll
2020-10-19 20:59:48.605112: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0
2020-10-19 21:00:02.120333: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN)to use the following CPU instructions in performance-critical operations: AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2020-10-19 21:00:02.128143: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x255e4b0b0a0 initialized for platform Host (this does not guarantee that XLA will be used). Devices:
2020-10-19 21:00:02.128792: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): Host, Default Version
2020-10-19 21:00:03.014080: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1716] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce RTX 2060 computeCapability: 7.5
coreClock: 1.2GHz coreCount: 30 deviceMemorySize: 6.00GiB deviceMemoryBandwidth: 312.97GiB/s
2020-10-19 21:00:03.014776: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudart64_101.dll
2020-10-19 21:00:03.015127: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cublas64_10.dll
2020-10-19 21:00:03.015477: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cufft64_10.dll
2020-10-19 21:00:03.015822: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library curand64_10.dll
2020-10-19 21:00:03.016172: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusolver64_10.dll
2020-10-19 21:00:03.016565: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cusparse64_10.dll
2020-10-19 21:00:03.016911: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cudnn64_7.dll
2020-10-19 21:00:03.017288: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1858] Adding visible gpu devices: 0
2020-10-19 21:00:03.722569: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1257] Device interconnect StreamExecutor with strength 1 edge matrix:
2020-10-19 21:00:03.722942: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1263] 0
2020-10-19 21:00:03.723166: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1276] 0: N
2020-10-19 21:00:03.723522: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1402] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 4594 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2060, pci bus id: 0000:01:00.0, compute capability: 7.5)
2020-10-19 21:00:03.726833: I tensorflow/compiler/xla/service/service.cc:168] XLA service 0x255883632b0 initialized for platform CUDA (this does not guarantee that XLA will be used). Devices:
2020-10-19 21:00:03.727297: I tensorflow/compiler/xla/service/service.cc:176] StreamExecutor device (0): GeForce RTX 2060, Compute Capability 7.5
2020-10-19 21:00:08.908192: I tensorflow/core/profiler/lib/profiler_session.cc:164] Profiler session started.
2020-10-19 21:00:08.908485: I tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1391] Profiler found 1 GPUs
2020-10-19 21:00:08.910553: I tensorflow/stream_executor/platform/default/dso_loader.cc:48] Successfully opened dynamic library cupti64_101.dll
2020-10-19 21:00:09.007043: I tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1513] CUPTI activity buffer flushed
2020-10-19 21:06:09.402869: I tensorflow/core/profiler/lib/profiler_session.cc:164] Profiler session started.
2020-10-19 21:06:09.403307: I tensorflow/core/profiler/internal/gpu/cupti_tracer.cc:1513] CUPTI activity buffer flushed
任何人都可以帮助我停止将这些消息打印到控制台,这使得在控制台上分析其他信息变得非常困难!
谢谢!

最佳答案

您可以使用 os.environ 禁用调试日志.

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
import tensorflow as tf
可能的值如下:
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

关于python - 停止 Tensorflow 打印到控制台,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64434655/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com