import torch.utils.tensorboard causes tensorflow warnings

20 Views Asked by At

As stated here tensorboard is part of tensorflow but does not depend on it. One can use it in pytorch such as

from torch.utils.tensorboard import SummaryWriter

It is, however, annoying that this import causes a long trace of tensorflow related warnings

2024-03-28 12:11:43.296359: I tensorflow/core/util/port.cc:110] 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`.                                                                              
2024-03-28 12:11:43.331928: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 AVX512F AVX512_VNNI FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-03-28 12:11:43.970865: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT

I wonder if this is necessary and / or how they can be (safely?) muted.

2

There are 2 best solutions below

0
Klops On

I found a solution that is not based on importing tensorflow (which I dont use) but allows muting through environment variables:

Simply add this line to the beginning of your script.

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '3'  # FATAL

This should work for any tensorflow > 1.14

1
Madhu Nathuram Kumawat On

If the warnings do not affect your code execution or performance, you can choose to ignore them.

import warnings
warnings.filterwarnings("ignore", category=FutureWarning)