I can't install TensorFlow-macos and TensorFlow-metal

Dear All,

I am a Data Scientist and waiting for GPU accelerating for years, and I am thrilled while Apple announced it will come at MacOS 12.

linkText

And so, I updated my OS to Monterey Beta and tried to install TensorFlow-Metal a few days ago. However, all installing instruction commands not work at all.

After that, I looked into pypi.org and found out there are whl files for TensorFlow-macos and TensorFlow-metal. So, I tried to pip install both whl files. Yet, noting work again.

Here is the screenshot for installing.

I would very much appreciate if you can help me to solve this issue.

Sincerely,

  • hey hawkiyc, if you resolve the issue, please share with me how. cuz i am facing that issue rn.

Add a Comment

Accepted Reply

I was able to install tensorflow-macos and tensrflow-metal on intel based iMac

$ python3 -m venv tensorflow-metal-test
$ source tensorflow-metal-test/bin/activate
$ cd tensorflow-metal-test/
$ python -m pip install -U pip
$ pip install tensorflow-macos
$ pip install tensorflow-metal

and my version

$ python -V
Python 3.8.2
$ pip -V
pip 21.1.2 from /Us...
$ pip list
Package                 Version
----------------------- -------------------
absl-py                 0.13.0
astunparse              1.6.3
cachetools              4.2.2
certifi                 2021.5.30
chardet                 4.0.0
flatbuffers             1.12
gast                    0.4.0
google-auth             1.32.0
google-auth-oauthlib    0.4.4
google-pasta            0.2.0
grpcio                  1.34.1
h5py                    3.1.0
idna                    2.10
keras-nightly           2.5.0.dev2021032900
Keras-Preprocessing     1.1.2
Markdown                3.3.4
numpy                   1.19.5
oauthlib                3.1.1
opt-einsum              3.3.0
pip                     21.1.2
protobuf                3.17.3
pyasn1                  0.4.8
pyasn1-modules          0.2.8
requests                2.25.1
requests-oauthlib       1.3.0
rsa                     4.7.2
setuptools              41.2.0
six                     1.15.0
tensorboard             2.5.0
tensorboard-data-server 0.6.1
tensorboard-plugin-wit  1.8.0
tensorflow-estimator    2.5.0
tensorflow-macos        2.5.0
tensorflow-metal        0.1.1
termcolor               1.1.0
typing-extensions       3.7.4.3
urllib3                 1.26.6
Werkzeug                2.0.1
wheel                   0.36.2
wrapt                   1.12.1
  • Thank you very much for your information. This problem resulted from Python 3.9. I succeeded in installing tf-macos and tf-metal in a python 3.8 env.

  • Can you recreate how you were able to get it to work after using a python 3.8 environment? I had the same issue with python 3.9.5, but when I load a python 3.8 environment I still get the same error:

    (tensorflow-metal) ~ % python -V Python 3.8.10 (tensorflow-metal) ~ % 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
  • How did you get Python 3.8? I am on Monterey release now and System python3 is 3.7: which python3 -> /usr/bin/python3; python3 --version ->  Python 3.7.3. Installing Python 3.8 from anaconda or python.org both still give me the error in the original post.

Replies

I'll add that like others, python 3.8.X is required.

Then run:

SYSTEM_VERSION_COMPAT=0 python -m pip install tensorflow-macos (this will give you tensorflow-macos version 2.7 - don't get excited yet)

SYSTEM_VERSION_COMPAT=0 python -m pip install tensorflow-metal (this will also succeed)

Install your other stuff as normal with conda (pandas, scikit-learn, jupyterlab, etc)

Then run your code. You can run:

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

Num GPUs Available: 1

So far so good right?!?! Looking Good!

Now run your model...

First line:

Metal device set to: AMD Radeon Pro 5600M keeps looking better and better !!!

and then the kernel dies...

2022-01-13 17:02:36.447465: I tensorflow/core/platform/cpu_feature_guard.cc:151] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations: AVX2 FMA To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags. 2022-01-13 17:02:36.448221: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:305] Could not identify NUMA node of platform GPU ID 0, defaulting to 0. Your kernel may not have been built with NUMA support. 2022-01-13 17:02:36.448581: I tensorflow/core/common_runtime/pluggable_device/pluggable_device_factory.cc:271] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 0 MB memory) -> physical PluggableDevice (device: 0, name: METAL, pci bus id: <undefined>)

Will tensorflow-macos ever work for Intel ?

In my case I am using Miniconda.

I also encountered encountered the above problem. But when I installed python 3.8 in a new environment (So that my other dependencies are not affected), I was able to solve the issue.(Mine is M1 Pro chip, May also work for M1 and M1 max)

conda create --name tensor-env  python = 3.8      #creating new environment named "tensor-env" with python version 3.8
conda activate tensor-env

# All the below 3 installation is necessary to make use of M1's GPU  

conda install -c apple tensorflow-deps
python -m pip install tensorflow-macos
python -m pip install tensorflow-metal

And if all the above installations are successful, then you can use Tensorflow which is designed to be used in Apple M1 GPU.

Hi all, I am using Monterey, version 12.3.1, M1 chip. The following procedures work for me on Python 3.9.12.

  1. create virtual environment and active it.

 python3 -m venv test_env

 source test_env/bin/activate

  1. use brew to install hdf5 first and export the path

 brew install hdf5

 export HDF5_DIR=/opt/homebrew/Cellar/hdf5/1.12.2

  1. install packages via pip3

 pip3 install --no-binary=h5py h5py

 pip3 install tensorflow-macos

 pip3 install tensorflow-metal

Hope it will help you. :)

TensorFlow for M1 till support up to python 3.8 [as per 16th Feb 2023]

  1. install conda [miniconda]
  2. create virtual env with conda for python version 3.8
  3. activate into that virtual env
  4. now run commands to install tensorflow and related lib

Thanks

I'm having same issue on m1 mac using python 3.10.10 and pip 23.0.1. According to google docs python up to 3.11 should work.

Just a head up - wIth M3 Max I'm not see ing Meta with Python 3.12.3 (Sonoma 14.4.1)

python -m pip install tensorflow-metal ERROR: Could not find a version that satisfies the requirement tensorflow-metal (from versions: none) ERROR: No matching distribution found for tensorflow-metal