Stupid420
Stupid420

Reputation: 1419

Disabling the logs from Tensorflow Keras

I am using the following code to see If I am able to stop TF/KERAS from producing logs.

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)

Here you may see that I have used os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3' in my code to disable logs.

Num GPUs Available: 1 Executing op MatMul in device /job:localhost/replica:0/task:0/device:GPU:0 tf.Tensor( [[22. 28.] [49. 64.]], shape=(2, 2), dtype=float32)

Is there any way I can disable TF/KERAS to print Executing op MatMul in device /job:localhost/replica:0/task:0/device:GPU:0 ?

Upvotes: 1

Views: 800

Answers (1)

Laplace Ricky
Laplace Ricky

Reputation: 1687

Remove the following line and you can get rid of the ops device placement messages:

tf.debugging.set_log_device_placement(True)

Upvotes: 2

Related Questions