Can I print only progress bar on my terminal with MirroredStrategy?

I built semantic segmentation model with Tensorflow 2.13.1.

I wanted using Multiple GPUs when training, so applied MirroredStrategy like:

strategy = tf.distribute.MirroredStrategy(cross_device_ops=tf.distribute.HierarchicalCopyAllReduce())
with strategy.scope():
    model = deeplabv3plus.DeepLabV3_plus(num_classes=n_classes)
    model.compile(optimizer=tf.keras.optimizers.Adam(learning_rate=1e-4),
                  loss=tf.keras.losses.CategoricalCrossentropy(from_logits=True),
                  metrics=[tf.keras.metrics.Accuracy(),
                           tf.keras.metrics.OneHotIoU(num_classes=n_classes, target_class_ids=range(1, n_classes)),
                           tf.keras.metrics.OneHotMeanIoU(num_classes=n_classes, ignore_class=[0]),
                           ])

and applying model.fit() is:

model.fit(train_dataset,
          epochs=1000,
          callbacks=[tensorboard_callback, checkpoint, early_stopping],
          validation_data=val_dataset,
          validation_freq=2,
          steps_per_epoch=len(train_images)//batch,
          validation_steps=len(val_images)//batch,
          )

It worked nicely, but it shows a lot of messages that I cannot see the progress bar like below:

I want to see the progress bar only, so what can I do for it?

I tried using TF_CPP_MIN_LOG_LEVEL with os variable and tf.compat.v1.logging.set_verbosity but they did not work.

Hi @whansk50

Welcome to the TensorFlow Forum!

Please use below code before importing Tensorflow on top of your code to suppress these warning or informational messages:

import os
os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

import tensorflow as tf