I have to configure TensorFlow logs according to the project logging style (colorlogs, formatters, etc.). The project logging configuration is described in a .yaml file, which is then passed to the logging.dictConfig()
method. The TensorFlow logger ‘tensorflow’, which can be retrieved by calling tf.get_logger()
obeys the logging
configuration settings (proven by the WARNING message called upon the performance of the callbacks). However, the under the hood TensorFlow logger is not configured using this method. By ‘under the hood’ I mean the logger (or other logging instance) called at the import stage, which logs useful stats:
2024-06-11 13:49:34.476834: I tensorflow/core/platform/cpu_feature_guard.cc:193] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2024-06-11 13:49:34.625877: W tensorflow/core/common_runtime/gpu/gpu_bfc_allocator.cc:42] Overriding orig_value setting because the TF_FORCE_GPU_ALLOW_GROWTH environment variable is set. Original config value was 0.
2024-06-11 13:49:34.625992: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1616] Created device /device:GPU:0 with 5563 MB memory: -> device: 0, name: NVIDIA GeForce RTX 4060, pci bus id: 0000:01:00.0, compute capability: 8.9
Mutting tensorflow under the hood logging by setting os.environ['TF_CPP_MIN_LOG_LEVEL']
to high levels is not a good solution. I even tried to get all loggers before and after importing tensorflow and configure newly added manually (adding them to the .yaml file), but this didn’t help (and and this is quiet unnecessary because all loggers inherit from the root logger). I suppose the logging style is defined in the compiled tf modules (the env variable refers to CPP). Do you have any ideas how to configure the tensorflow under the hood logger? (tensorflow version 2.10, Python 3.10)