How can I check the GPU accessibility with Tensorflow on Mac of Apple M1 silicon?

Viewed 1982

I'm using Tensorflow 2.4.0 on Macbook(arm64, M1 silicon), I get this output after I wanted to check if the GPU in M1 silicon can be used by Tensorflow:

My code:

import tensorflow as tf
print(tf.test.gpu_device_name())
print(tf.config.list_physical_devices('GPU'))

The output:


[]

It looks like my GPU is unavailable. How should I use my GPU on M1 to accelerate trainning?

2 Answers

As of July 2021 Apple provide the following instructions to install Tensorflow 2.5 and the tensorflow-metal plugin:

  1. Create a new conda environment;
  2. Run conda install -c apple tensorflow-deps
  3. Install tensorflow: python -m pip install tensorflow-macos; then
  4. Install the plugin: python -m pip install tensorflow-metal.

This will give you access to the M1 GPU in Tensorflow.

Related