【问题标题】:Disabling the logs from Tensorflow Keras从 Tensorflow Keras 禁用日志
【发布时间】:2021-06-23 07:50:36
【问题描述】:

我正在使用以下代码查看是否能够阻止 TF/KERAS 生成日志。

import tensorflow as tf
import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'
print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

tf.debugging.set_log_device_placement(True)

# Create some tensors
a = tf.constant([[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]])
b = tf.constant([[1.0, 2.0], [3.0, 4.0], [5.0, 6.0]])
c = tf.matmul(a, b)

print(c)

您可能会看到我在代码中使用了os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' 来禁用日志。

可用的 GPU 数量:1 在设备中执行 op MatMul /job:localhost/replica:0/task:0/device:GPU:0 tf.Tensor([[22. 28.] [49. 64.]], shape=(2, 2), dtype=float32)

有什么方法可以禁用 TF/KERAS 打印Executing op MatMul in device /job:localhost/replica:0/task:0/device:GPU:0

【问题讨论】:

    标签: tensorflow keras


    【解决方案1】:

    删除以下行,您可以摆脱 ops device placement 消息:

    tf.debugging.set_log_device_placement(True)
    

    【讨论】:

      猜你喜欢
      • 2022-09-29
      • 2022-11-29
      • 2019-12-23
      • 2015-02-14
      • 2021-07-04
      • 1970-01-01
      • 1970-01-01
      • 2017-08-21
      • 2013-01-31
      相关资源
      最近更新 更多