Broken compatibility in tensorflow-metal with tensorflow 2.18

Issue type: Bug

TensorFlow metal version: 1.1.1

TensorFlow version: 2.18

OS platform and distribution: MacOS 15.2

Python version: 3.11.11

GPU model and memory: Apple M2 Max GPU 38-cores

Standalone code to reproduce the issue:

import tensorflow as tf

if __name__ == '__main__':
    gpus = tf.config.experimental.list_physical_devices('GPU')
    print(gpus)

Current behavior

Apple silicone GPU with tensorflow-metal==1.1.0 and python 3.11 works fine with tensorboard==2.17.0

This is normal output:

/Users/mspanchenko/anaconda3/envs/cryptoNN_ml_core/bin/python /Users/mspanchenko/VSCode/cryptoNN/ml/core_second_window/test_tensorflow_gpus.py 
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

Process finished with exit code 0

But if I upgrade tensorflow to 2.18 I'll have error:

/Users/mspanchenko/anaconda3/envs/cryptoNN_ml_core/bin/python /Users/mspanchenko/VSCode/cryptoNN/ml/core_second_window/test_tensorflow_gpus.py 
Traceback (most recent call last):
  File "/Users/mspanchenko/VSCode/cryptoNN/ml/core_second_window/test_tensorflow_gpus.py", line 1, in <module>
    import tensorflow as tf
  File "/Users/mspanchenko/anaconda3/envs/cryptoNN_ml_core/lib/python3.11/site-packages/tensorflow/__init__.py", line 437, in <module>
    _ll.load_library(_plugin_dir)
  File "/Users/mspanchenko/anaconda3/envs/cryptoNN_ml_core/lib/python3.11/site-packages/tensorflow/python/framework/load_library.py", line 151, in load_library
    py_tf.TF_LoadLibrary(lib)
tensorflow.python.framework.errors_impl.NotFoundError: dlopen(/Users/mspanchenko/anaconda3/envs/cryptoNN_ml_core/lib/python3.11/site-packages/tensorflow-plugins/libmetal_plugin.dylib, 0x0006): Symbol not found: __ZN3tsl8internal10LogMessageC1EPKcii
  Referenced from: <D2EF42E3-3A7F-39DD-9982-FB6BCDC2853C> /Users/mspanchenko/anaconda3/envs/cryptoNN_ml_core/lib/python3.11/site-packages/tensorflow-plugins/libmetal_plugin.dylib
  Expected in:     <2814A58E-D752-317B-8040-131217E2F9AA> /Users/mspanchenko/anaconda3/envs/cryptoNN_ml_core/lib/python3.11/site-packages/tensorflow/python/_pywrap_tensorflow_internal.so

Process finished with exit code 1
Answered by Graphics and Games Engineer in 824255022

@mspanchenko @rahal A new tensorflow-metal wheel was released which should resolve 2.18 compatibility issues: https://pypi.org/project/tensorflow-metal/#history

Could you please try updating tensorflow-metal and reply here if the issue persists? Thanks!

The question itself solved my issue of running tensorflow on a Mac-book. Thanks

Accepted Answer

@mspanchenko @rahal A new tensorflow-metal wheel was released which should resolve 2.18 compatibility issues: https://pypi.org/project/tensorflow-metal/#history

Could you please try updating tensorflow-metal and reply here if the issue persists? Thanks!

I have had a similar question and problem en MacOs 14.7. In the documentation of tensorflow from version 2.16 onwards it is recommended to use "pip install tensorflow" and not other methods. Note that when using conda or poetry this same failure occurs.

You can use the following lines as a guide, install Python 3.11 -or3.12 -version 3.13 is not yet supported by TF-, Tensorflow2.18 -or 2.17-, keras 3.8 and tensorflow-metal1.2 (tensorflow-macos and others are not required)

conda create -name <Environment Name> python 3.12.9 
conda activate <Environment name> 
pip install tensorflow==2.17 or 2.18 tensorflow-metal 
conda install -c conda-forge <other package name>

verify to status:

python --version
python -c "import tensorflow as tf; import keras ; print(tf.__version__); print(keras.__version__)"
python -c "import tensorflow as tf; print(tf.config.list_physical_devices(‘GPU'))"

sure it will be useful and you can tell us if it works in MacOS15

Broken compatibility in tensorflow-metal with tensorflow 2.18
 
 
Q