Install tensorflow-macos version error

I'm trying to install tensorflow with metal support on my 16" macbook pro (intel) using these steps:

Getting Started with tensorflow-metal PluggableDevice

Based on issue 683757, I used a python 3.8 environment, but I still got the same error:

(tensorflow-metal_env) (base) f@As-MBP Environments % pip list
Package  Version
---------- -------
pip    21.1.3
setuptools 57.0.0
wheel   0.36.2
(tensorflow-metal_env) (base) f@As-MBP Environments % python -m pip install tensorflow-macos

ERROR: Could not find a version that satisfies the requirement tensorflow-macos (from versions: none)
ERROR: No matching distribution found for tensorflow-macos
(tensorflow-metal_env) (base) f@As-MBP Environments % python -V
Python 3.8.1

How can I get tensorflow-macos installed?

Thanks for the help! Adam

Accepted Reply

I’ve installed it on my Mac Mini M1 (straightforward, follow the instructions) and on my MBP 16, in both cases obviously running MacOS 12 Monterey. The later (on Intel) was less obvious but in short, you do not required a conda environment (such as Miniforge), you want Apple’s native Python. However, the one that ships with the OS is 2.7, therefore you should run:

    xcode-select --install

This will install python 3.8.2 built with clang 13, and to make sure you are getting version 3 run it as python3. Now go back to the instructions, and create a python venv (ignore the optional bit), then install the latest version of pip. Finally pip install the tensorflow-macos and tensorflow-metal packages. Done!

To verify the installation, fire up python and run the following code:

  import tensorflow as tf

  devices = tf.config.list_physical_devices()
  print(devices)

You should now see CPU0 and GPU0 listed!

  • that did it, thanks! for others who run into this issue too, you need to make sure you use virtualenv, and point to the Apple version of Python 3. The venv that comes with Python 3 just uses the most up to date Python, which for me was Python 3.9.5. The Apple Python 3 was in /usr/bin/python3, so something like virtualenv -p /usr/bin/python3 myenv

  • I am curious in your comment above you mentioned about Python 3.9.5 but in the posting above : python -V is 3.8.1 . Were you using the miniforge3 for Intel and created python3.8 environment from that ? Our recommendation is to create the virtualenv using system python3:

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

    Let us know if it doesn't work.

Add a Comment

Replies

I’ve installed it on my Mac Mini M1 (straightforward, follow the instructions) and on my MBP 16, in both cases obviously running MacOS 12 Monterey. The later (on Intel) was less obvious but in short, you do not required a conda environment (such as Miniforge), you want Apple’s native Python. However, the one that ships with the OS is 2.7, therefore you should run:

    xcode-select --install

This will install python 3.8.2 built with clang 13, and to make sure you are getting version 3 run it as python3. Now go back to the instructions, and create a python venv (ignore the optional bit), then install the latest version of pip. Finally pip install the tensorflow-macos and tensorflow-metal packages. Done!

To verify the installation, fire up python and run the following code:

  import tensorflow as tf

  devices = tf.config.list_physical_devices()
  print(devices)

You should now see CPU0 and GPU0 listed!

  • that did it, thanks! for others who run into this issue too, you need to make sure you use virtualenv, and point to the Apple version of Python 3. The venv that comes with Python 3 just uses the most up to date Python, which for me was Python 3.9.5. The Apple Python 3 was in /usr/bin/python3, so something like virtualenv -p /usr/bin/python3 myenv

  • I am curious in your comment above you mentioned about Python 3.9.5 but in the posting above : python -V is 3.8.1 . Were you using the miniforge3 for Intel and created python3.8 environment from that ? Our recommendation is to create the virtualenv using system python3:

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

    Let us know if it doesn't work.

Add a Comment

Hi @Simon Benvenutto, Can you see if below helps?

SYSTEM_VERSION_COMPAT=0 python -m pip install tensorflow-macos

You can check if your issue is same as : https://developer.apple.com/forums/thread/687785

  • thanks it worked for me. Struggled for a long time.

Add a Comment