tensorflow-metal plugin errors

I followed the documentation the install tensorflow-metal but when I ran the verification example on that page I am getting a bunch of errors

11490434/11490434 [==============================] - 0s 0us/step
2023-01-07 17:01:16.644549: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:306] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support.
2023-01-07 17:01:16.644938: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:272] 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>)
Metal device set to: Apple M2
2023-01-07 17:01:16.907085: W tensorflow/tsl/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
Epoch 1/5
2023-01-07 17:01:17.101099: I tensorflow/core/grappler/optimizers/custom_graph_optimizer_registry.cc:114] Plugin optimizer for device_type GPU is enabled.
2023-01-07 17:01:17.538659: W tensorflow/core/framework/op_kernel.cc:1830] OP_REQUIRES failed at xla_ops.cc:418 : NOT_FOUND: could not find registered platform with id: 0x11aeca870

Hi!

I've been facing this issue for a few days and it worked when I changed the optimizer from

model.compile(optimizer="adam", loss=loss_fn, metrics=["accuracy"])

to:

model.compile(optimizer=tf.keras.optimizers.legacy.Adam(), loss=loss_fn, metrics=["accuracy"])

Got the fix from here: https://developer.apple.com/forums/thread/722873.

Quoting the other post:

Is this on the latest wheels with tensorflow-macos==2.11 and tensorflow-metal==0.7.0? In that case has to do with recent changes on tensorflow side for version 2.11 where a new optimizer API has been implemented

Hope that helps!

Yes. I've just tested with the latest wheels for Tensorflow-Macos (2.11) and Tensorflow-Metal (.7). The only catch is that you need to use Python 3.9 in your environment. For some reason, Python 3.10 and 3.11 don't seem to be working.

Steps I used (after mini forge installation).

-- conda create -n tf

-- conda activate tf

-- conda install python==3.9

-- pip install tensorflow-macos

-- pip install tensorflow-metal

As mentioned above, you do need to change the test script provided to account for the deprecation of the Adam optimizer. After doing that, everything worked great for me.

tensorflow-metal plugin errors
 
 
Q