How to install Tensorflow on the Apple M1 Notebook

Following the instructions at

https://developer.apple.com/metal/tensorflow-plugin/

I got as far as

python -m pip install tensorflow-macos

and it responded "ERROR: Could not find a version that satisfies the requirement tensorflow-macos (from versions: none) ERROR: No matching distribution found for tensorflow-macos"

I'd be grateful for any suggestions

Answered by rodmclaughlin in 684301022

Thanks for your answer, but my Python is 3.8.5. Calling 'python3' causes the same error.

python3 -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

python3 --version

Python 3.8.5

I am encountering the same problem with every approach I take. Why can't you all just work in the beta and try to give us an ETA? All you have done is made the repository questions read only. This might just make me switch over to a Windows machine...

python -m pip install tensorflow-macos will run Python 2 and ask it to install tensorflow which is why you're getting the error that there is no such distribution. You should change the command instead to python3 -m pip install tensorflow-macos and it will work.

If it doesn't that means there is no python 3 in your system (which you can get from Anaconda or just brew install python3 )

For more instructions on Tensorflow installation, you should follow this link : https://www.tensorflow.org/install/pip#macos

Accepted Answer

Thanks for your answer, but my Python is 3.8.5. Calling 'python3' causes the same error.

python3 -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

python3 --version

Python 3.8.5

See also https://stackoverflow.com/questions/56604348/how-to-install-tensorflow-2-0-on-mac-or-linux.

This covers the efforts of several developers to use several methods to get ML working on a Mac - all have run into dead-ends.

Thanks, Pummelchen! I'll try that.

I got locked out of my Apple account for a month - I can't remember why, but I've only just got back in. Meanwhile, I've managed to get Tensorflow working on a MacPro M1 - NO THANKS TO APPLE.

Details here: https://stackoverflow.com/questions/56604348/how-to-install-tensorflow-2-0-on-mac-or-linux/68634948#68634948

Please, I need help to run M1 native Python again!

I'd been successfully running M1 native Python code on a MacBook Pro (13-inch, M1, 2020) using Jupyter Notebook, but since 10/13/2021 the notebook kernel dies as soon as the M1 CPU is used intensively. The .py version of the same code aborts too. I have formatted the MacBook several times, followed the instructions on https://developer.apple.com/metal/tensorflow-plugin/ and the problem persists. I am running macOS Big Sur 11.6. As a remedy I am now running the same code on Anaconda (Rosetta) and it is taking 50% more time. We have more than 50 data scientists in our company and I am leading a research on CoreML and the adoption of the new MacBook Pro as a standard platform to our developers. I would appreciate very much any help from Apple support or the developers community.

The test code is as follows:

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

%%time import tensorflow.compat.v2 as tf import tensorflow_datasets as tfds

tf.enable_v2_behavior()

from tensorflow.python.framework.ops import disable_eager_execution disable_eager_execution()

(ds_train, ds_test), ds_info = tfds.load( 'mnist', split=['train', 'test'], shuffle_files=True, as_supervised=True, with_info=True, )

def normalize_img(image, label): """Normalizes images: uint8 -> float32.""" return tf.cast(image, tf.float32) / 255., label

batch_size = 128

ds_train = ds_train.map( normalize_img, num_parallel_calls=tf.data.experimental.AUTOTUNE) ds_train = ds_train.cache() ds_train = ds_train.shuffle(ds_info.splits['train'].num_examples) ds_train = ds_train.batch(batch_size) ds_train = ds_train.prefetch(tf.data.experimental.AUTOTUNE)

ds_test = ds_test.map( normalize_img, num_parallel_calls=tf.data.experimental.AUTOTUNE) ds_test = ds_test.batch(batch_size) ds_test = ds_test.cache() ds_test = ds_test.prefetch(tf.data.experimental.AUTOTUNE)

model = tf.keras.models.Sequential([ tf.keras.layers.Conv2D(32, kernel_size=(3, 3), activation='relu'), tf.keras.layers.Conv2D(64, kernel_size=(3, 3), activation='relu'), tf.keras.layers.MaxPooling2D(pool_size=(2, 2)),

tf.keras.layers.Dropout(0.25),

tf.keras.layers.Flatten(), tf.keras.layers.Dense(128, activation='relu'),

tf.keras.layers.Dropout(0.5),

tf.keras.layers.Dense(10, activation='softmax') ]) model.compile( loss='sparse_categorical_crossentropy', optimizer=tf.keras.optimizers.Adam(0.001), metrics=['accuracy'], )

model.fit( ds_train, epochs=12, validation_data=ds_test, )

Why is this question and its responses marked read only? This given that it is such an important topic affecting the adoption of Macbook Pro M1's.

There is no published method for installing Tensorflow, the leading ML API, on a Macbook Pro M1 that actually works without breaking something else. An example of this is using conda to install the environment and using another installer for the metal plugin. The conflict comes because conda wants to define and control the environment so that there is compatibility between versions of Python and the litany of libraries required.

This reminds me of what Steve said after the Mobile Me debacle. Do you remember what he said after one of the engineers gave a long explanation? It might be worth a look.

For maximum adoption of this platform, it needs to play well with others, especially given the hotbed of research in this area. I can't compete with PC+NVIDIA and that is costing both time and money - A lot of money in the case of the Macbook Pro M1.

 note: This error originates from a subprocess, and is likely not a problem with pip.
 ERROR: Failed building wheel for numpy
Failed to build grpcio h5py numpy

I'm getting a lenghty error but also cannot install using this command on M1

If anyone's still facing issues, there are up-to-date installation steps (for TF and Torch) here: https://github.com/fastestimator/fastestimator/issues/1224

This might be more complex than you need for your particular use-case (it involves putting conda inside a virtual environment to keep it isolated from the rest of the system), but it has worked for at least 2 people

I had the same problem but I have used the following tutorial and everything worked smoothly: https://caffeinedev.medium.com/how-to-install-tensorflow-on-m1-mac-8e9b91d93706

P.S.: I have nothing to do with the tutorial, I have just used it...

python 3.8 doesn't work for me either but with python 3.5 it worked

I found the following resources helpful to me with the same issue.

https://developer.apple.com/metal/tensorflow-plugin/

https://stackoverflow.com/questions/70315694/vs-code-install-tensorflow-on-mac-m1-mini

I don't think either suggested solution worked on its own for me, but the combined info in those posts helped me figure it out for my particular environment.

UPDATE: I found another guide that another person posted in the comments here...it seems to be helpful as well:

https://caffeinedev.medium.com/how-to-install-tensorflow-on-m1-mac-8e9b91d93706

This resolved the issue for my M1 Mac: https://caffeinedev.medium.com/how-to-install-tensorflow-on-m1-mac-8e9b91d93706

How to install Tensorflow on the Apple M1 Notebook
 
 
Q