Suppress tensorflow-metal initialization messages

Viewed 43

I have a macbook pro m1 max and installed tensorflow via tensowflow-apple-download.

I get the following logs every time I run a script that uses keras or tensorflow:

>>>  python script.py
Metal device set to: Apple M1 Max

systemMemory: 32.00 GB
maxCacheSize: 10.67 GB

2022-09-06 02:35:38.603010: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2022-09-06 02:35:38.603133: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)
2022-09-06 02:35:38.659578: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
2022-09-06 02:35:38.684142: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:113] Plugin optimizer for device_type GPU is enabled.

Most of the logs are irrelevant and I was able to suppress some by:

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

However I can't disable these logging info:

>>>  python script.py
Metal device set to: Apple M1 Max

systemMemory: 32.00 GB
maxCacheSize: 10.67 GB

Is there any way to make keras and tensorflow-metal silent? I don't want these logs.

I have already tried without success:

import tensorflow as tf
tf.get_logger().setLevel('ERROR')
tf.compat.v1.logging.set_verbosity(tf.compat.v1.logging.ERROR)
tf.autograph.set_verbosity(2)

import logging
logging.getLogger('tensorflow').setLevel(logging.ERROR)

Note: Uninstalling tensorflow-metal seems to suppress the logging info, however the solution is not optimal since tensorflow will run on CPU instead of GPU...

>>> pip uninstall tensorflow-metal

I think the logging present is now due to calling keras Sequential():

from keras.models import Sequential

model = Sequential()
0 Answers
Related