Cannot install Tensorflow on Mac m1

I try to install and fix the tensorflow on my new Mac m1 following a lot the instuctions in the internet but it's not work. The kernel will died when try to import tensorflow.

`(tensorflow-metal) ampnapat@Amps-MacBook-Pro ~ % 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) ampnapat@Amps-MacBook-Pro ~ % 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`

Replies

Needs macOS 12.0+?

Not sure if this directly helps you, but I was getting errors following Apple's guide.

I don't actually recall the steps I took to get here (with TF 2.5 and Metal support for GPU), but I made this to share the environment. Please let me know on the repo if it doesn't work! (or does!)

https://github.com/ctrahey/m1-tensorflow-config

  • @ctrahey yours is the only solution that works for me as of 26 SEPT 2021. Default instructions from Apple install but importing tensorflow crashes python. I haven't installed jupyter or tried to load or execute my neural networks, but at least your scripts got me an environment where tensorflow doesn't immediately crash. Thanks for sharing.

  • The approach and scripts mentioned above from @ctrahey worked to resolve the inability to import tensorflow into python. However, I still encountered a runtime error during model.fit() due to incompatibility in pandas. I noticed that my python and numpy were installed by conda-forge, while pandas was installed by pip. I uninstalled pandas using pip, reinstalled it using conda-forge, and the runtime error was resolved. Back to working on my loss function and training my model (where I was 2 weeks ago before deciding to try to get all this running natively instead of under the emulator).

Add a Comment

If you're comfortable not using conda, you can follow the guide I linked in this post: https://developer.apple.com/forums/thread/687654

  • the guide is last link in the post

I don't just get it work even if I followed strictly the guide given at https://developer.apple.com/metal/tensorflow-plugin/

ImportError:

IMPORTANT: PLEASE READ THIS FOR ADVICE ON HOW TO SOLVE THIS ISSUE!

Importing the numpy C-extensions failed. This error can happen for many reasons, often due to issues with your setup or how NumPy was installed.

We have compiled some common reasons and troubleshooting tips at:

https://numpy.org/devdocs/user/troubleshooting-importerror.html

Please note and check the following:

  • The Python version is: Python3.9 from "/Users/mattihonkanen/miniforge3/bin/python"
  • The NumPy version is: "1.19.5"

and make sure that they are the versions you expect. Please carefully study the documentation linked above for further help.

  • Yes, this numpy version requirement can be a great source of troubles. Tensorflow won't work with a higher version. There was a post about it and apple answered that this was the version recommended by Tensorflow so they just followed the recommandation.

  • As the same, how to fix it? choose lower version numpy? thanks

Add a Comment

I've installed Tensorflow multiple time on Mac M1 using this guide https://developer.apple.com/metal/tensorflow-plugin/

Just follow it step by step, don't skip the miniforge3 installation, it is absolutely mandatory to install and use the one provided in the guide.

Tested on python 3.8 and 3.9. Tensorflow is not supported on 3.10 (yet)