Installing tensorflow-macos on Non-M1 Devices

I wanted to share how I was able to install tensorflow-macos and tensorflow-metal with non-M1 Hardware.

Installing it on my M1 Mac Mini was straight forward with miniforge, but ran into issues with installation on my non-M1 device. (Also with miniforge)

Config:

  • MacOS 11.3 Beta
  • Radeon Vega Frontier

There's a workaround to installing from pip since it enforces platform checks.

  1. Download the whl files for tensorflow-macos and tensorflow-metal locally
  • https://pypi.org/project/tensorflow-macos/#files
  • https://pypi.org/project/tensorflow-metal/#files
  1. Rename the wheels:
  • tensorflow_macos-2.5.0-cp38-cp38-macosx_11_0_x86_64.whl -> tensorflow_macos-2.5.0-cp38-cp38-macosx_10_11_x86_64.whl
  • tensorflow_metal-0.1.1-cp38-cp38-macosx_11_0_x86_64.whl -> tensorflow_metal-0.1.1-cp38-cp38-macosx_10_11_x86_64.whl
  1. Run
pip install /path/to/tensorflow_macos-2.5.0-cp38-cp38-macosx_10_11_x86_64.whl && pip install /path/to/tensorflow_metal-0.1.1-cp38-cp38-macosx_10_11_x86_64.whl
  1. Check whether GPU is detected:
python3 -c "import tensorflow as tf; physical_devices = tf.config.list_physical_devices('GPU'); print('Num GPUs:', len(physical_devices)); print(physical_devices)"

# > Init Plugin
# > Init Graph Optimizer
# > Init Kernel
# > Num GPUs: 1
# > [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]

Hopefully this helps someone! I'm super stoked to finally get GPU support on MacOS

Hi,

Thanks. You could also create virtual environment to install the tensorflow-macos and tensorflow-metal packages without renaming.

Environment setup

python3 -m venv ~/tensorflow-metal
source ~/tensorflow-metal/bin/activate
python -m pip install -U pip

Install tensorflow base

python -m pip install tensorflow-macos

Install metal plugin

python -m pip install tensorflow-metal

Please let us know if you run into any issues.

Installing tensorflow-macos on Non-M1 Devices
 
 
Q