Unable to Use M1 Mac Pro Max GPU for TensorFlow Model Training

Hi Everyone,

I'm currently facing an issue where TensorFlow is unable to detect the GPU on my M1 Mac for model training. When I run the following code to check for available GPUs:

import tensorflow as tf

print("Num GPUs Available: ", len(tf.config.list_physical_devices('GPU')))

Num GPUs Available: 0

I have already applied the steps mentioned in the developer apple document. https://developer.apple.com/metal/tensorflow-plugin/

System Information:

Device: M1 Mac Pro Max

Python Version: 3.12.2

TensorFlow Version: 2.17.0

OS: macOS Sequoia (15.1)

Questions:

Is there any additional configuration required to enable GPU support on M1 Macs?

Are there specific TensorFlow versions that I should be using for better compatibility?

Has anyone else faced this issue, and how did you resolve it?

Hi, Just starting at Dev/ML, so I could be wrong, and I do not know how it works through Conda, but I tensorflow-metal, version 1.1.0/Sept2023 does not install with python 3.12. At the document/link that you points even specify explicitly python 3.9

I managed install it with python 3.10/3.11 and tensorflow 2.17.x

Regards

Hi, I had a similar problem in M1Pro(14.7) to do ML/AI, after checking different combinations of python, tensorflow, keras environments, these steps allowed me to operate with more current versions TF2.17-2.18,keras 3.8 & python3.12

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

Automatic installation of tensorflow-metal 1.2 to check installation 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('CPU'))”
 python -c "import tensorflow as tf; print(tf.config.list_physical_devices(‘GPU'))"

In the tensorflow documentation from version 2.16 onwards it is recommended to use "pip install tensorflow" and not other methods like conda or poetry. I have tested it for CIfar100 and MNIST and the code in keras2 and keras3 works on the local machine.

You should see a similar result:

I hope you find it useful and successful!!

Unable to Use M1 Mac Pro Max GPU for TensorFlow Model Training
 
 
Q