Skip to content
This repository has been archived by the owner on Jun 9, 2021. It is now read-only.

Tensorflow cannot be installed in Mac M1 because of error ERROR: numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl is not a supported wheel on this platform. #48

Open
monikavila opened this issue Dec 3, 2020 · 90 comments

Comments

@monikavila
Copy link

I am trying to install tensor flow in the new MacBook Pro M1 but it gives the error
ERROR: numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl is not a supported wheel on this platform.

@volvo007
Copy link

volvo007 commented Dec 4, 2020

I got the same issue. Not quite sure if we need to reinstall a lower version instead?

@ghost
Copy link

ghost commented Dec 4, 2020

I encountered the same problem when I installed it. How did you install TensorFlow? I finally downloaded https://github.com/apple/tensorflow_macos/releases and manually executed download_and_install. This method works for me.

@cbarkachi
Copy link

I encountered the same problem when I installed it. How did you install TensorFlow? I finally downloaded https://github.com/apple/tensorflow_macos/releases and manually executed download_and_install. This method works for me.

This didn't work for me :/

@ghost
Copy link

ghost commented Dec 4, 2020

Did you guys use anaconda?

@godkaieethu
Copy link

I got the same issue.and I have tried the similar issue for X86 but it doesn't work

@legrex
Copy link

legrex commented Dec 4, 2020

Same issue for me on Mac Mini M1 With Big Sur Beta. @pekoWANG what did you exactly with the downloaded archive along with the download_and_install-script?

@icenando
Copy link

icenando commented Dec 5, 2020

Same issue with me. Tried MANY different methods. Also tried older versions of tensorflow, but that also didn't work because it was the "wrong type of architecture" (referring to the new processor).

@monikavila
Copy link
Author

monikavila commented Dec 5, 2020

Same issue with me. Tried MANY different methods. Also tried older versions of tensorflow, but that also didn't work because it was the "wrong type of architecture" (referring to the new processor).

Yes, it is weird since Apple announced that tensor flow was optimised in MacBook Pro M1
"The Mac has long been a popular platform for developers, engineers, and researchers. With Apple’s announcement last week, featuring an updated lineup of Macs that contain the new M1 chip, Apple’s Mac-optimized version of TensorFlow 2.4 leverages the full power of the Mac with a huge jump in performance."

https://blog.tensorflow.org/2020/11/accelerating-tensorflow-performance-on-mac.html

We should contact Macbook Pro for a solution.

@godkaieethu
Copy link

godkaieethu commented Dec 6, 2020

hello guys I think I have found the solution.
first, uninstall anaconda and any python3 that you didn't download from apple.
then please xcode-select --install(maybe you can download Xcode from app store)
after that, you will get python3.8.2 from apple , please check if your python is 3.8.2 and it's path is/usr/bin/python3.
if succeed, run the install_venv.sh again.
ps:in the last step, you should build a new venv,or just delete the old venv on anaconda/python3 not downloaded from apple
and it works finally.

@roy-ren
Copy link

roy-ren commented Dec 6, 2020

hello guys I think I have found the solution.
first, uninstall anaconda and any python3 that you didn't download from apple.
then please xcode-select --install(maybe you can download Xcode from app store)
after that, you will get python3.8.2 from apple , please check if your python is 3.8.2 and it's path is/usr/bin/python3.
if succeed, run the install_venv.sh again.
ps:in the last step, you should build a new venv,or just delete the old venv on anaconda/python3 not downloaded from apple
and it works finally.

It's work for me

@icenando
Copy link

icenando commented Dec 6, 2020 via email

@godkaieethu
Copy link

So I installed Xcode and now don’t have any new python installed (only version 2.7.16, which is the version that comes with Big Sur. Any tips for getting puython from Xcode?

On 6 Dec 2020, at 11:34, roy @.***> wrote: hello guys I think I have found the solution. first, uninstall anaconda and any python3 that you didn't download from apple. then please xcode-select --install(maybe you can download Xcode from app store) after that, you will get python3.8.2 from apple , please check if your python is 3.8.2 and it's path is/usr/bin/python3. if succeed, run the install_venv.sh again. ps:in the last step, you should build a new venv,or just delete the old venv on anaconda/python3 not downloaded from apple and it works finally. It's work for me — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#48 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC64ESXCE7CYR3BUCTKUJATSTNT5BANCNFSM4UMRG5MA.

I download Xcode app and run ''xcode-select --install''at the same time so I can't find out where the python3.8.2 came from.how about trying downloading the Xcode command line tools for Xcode12.2 (you can find it in readme)and then bash '' xcode-select --install'' in the terminal?

@yarmun
Copy link

yarmun commented Dec 7, 2020

I got Tensor Flow working on my Anaconda Spyder.

As I was a noob to these, so let me share my detailed findings for other people in similar boat.

First I downloaded: https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha0/tensorflow_macos-0.1alpha0.tar.gz

After unzipping, there is 2 folders inside arm64 and x86_64. The first reaction is for people to install arm64, since we have the Mac M1 chip. But actually since we wanted to install into Anaconda which runs through Rosetta2 as an Intel, we should install x86_64, which will run slower, but at least you have all the libraries such as pandas and support apps.

To Install x86_64 into Anaconda (so I can run in Spyder):

  1. Anaconda start a new environment
  2. Uninstall tensorflow & tensorboard if exists
  3. Rename all the files inside the x86_64 folder from 11_0 to 10_16. Example: tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl
  4. In Conda console run below with 'username' replaced with your username:
    pip install pip wheel setuptools cached-property six
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/grpcio-1.33.2-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/h5py-2.10.0-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/numpy-1.18.5-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/scipy-1.5.4-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl"

Source: #7 (comment)

** To Install arm64 into virtualenv **
This would give the fastest speed since it uses the native arm64, but it doesn't support many libraries at the moment, including pandas.

To install:

  1. With tensorflow_macos unzipped in the Downloads folder
  2. In Terminal: browse to Downloads folder
  3. Run: /bin/bash ./tensorflow_macos/install_venv.sh --prompt
  4. Key in your desired path or just Enter for the default path

To Run:

  1. In a new terminal run: source /Users/username/tensorflow_macos_venv/bin/activate
  2. python3 "your_python_file.py"

To toggle between CPU and GPU runs adjust the device_name below:
from tensorflow.python.compiler.mlcompute import mlcompute
mlcompute.set_mlc_device(device_name='gpu')

To make it faster, turn off the default Eager mode with the following line:
tf.compat.v1.disable_eager_execution()

Run Speed Comparison for MNIST character recognition:
Anaconda Spyder (x86_64, EagerOff): 200-256us/sample
Terminal (arm64, CPU, EagerOff): 22-63us/sample
Terminal (arm64, GPU, EagerOff): 137-166us/sample

@monikavila
Copy link
Author

So I installed Xcode and now don’t have any new python installed (only version 2.7.16, which is the version that comes with Big Sur. Any tips for getting puython from Xcode?

On 6 Dec 2020, at 11:34, roy @.***> wrote: hello guys I think I have found the solution. first, uninstall anaconda and any python3 that you didn't download from apple. then please xcode-select --install(maybe you can download Xcode from app store) after that, you will get python3.8.2 from apple , please check if your python is 3.8.2 and it's path is/usr/bin/python3. if succeed, run the install_venv.sh again. ps:in the last step, you should build a new venv,or just delete the old venv on anaconda/python3 not downloaded from apple and it works finally. It's work for me — You are receiving this because you commented. Reply to this email directly, view it on GitHub <#48 (comment)>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC64ESXCE7CYR3BUCTKUJATSTNT5BANCNFSM4UMRG5MA.

I download Xcode app and run ''xcode-select --install''at the same time so I can't find out where the python3.8.2 came from.how about trying downloading the Xcode command line tools for Xcode12.2 (you can find it in readme)and then bash '' xcode-select --install'' in the terminal?

@godkaieethu Thanks a lot! I will try it :)

@tampapath
Copy link

I solved the "ERROR: numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl is not a supported wheel on this platform" by uninstalling the python 3.8 first and then re-installing it through the Xcode Command Line Tools. After that I ran the install script again and had no issues. If you install python directly it will not work and you will get the above error.

BTW I tested TF on M1 Mac Mini against TF on RTX 2080Ti and it ran 14% faster. I was so amazed that I posted it on Medium

https://tampapath.medium.com/m1-mac-mini-scores-higher-than-my-nvidia-rtx-2080ti-in-tensorflow-speed-test-9f3db2b02d74

@oresttokovenko
Copy link

@tampapath what is the Xcode Command Line code for the install?

@tampapath
Copy link

Hi simonaque, Go back to https://github.com/apple/tensorflow_macos site. Under the REQUIREMENTS: "Python 3.8, available from the Xcode Command Line Tools" click on the Command Line Tools link. That will get you to apples developers site. Sign in with your password and you will be presented with download links. Choose the one corresponding to the version of XCode that you have. Python 3.8 is included in the download. I hope this helps.

@mwidjaja1
Copy link

For anyone tuning in later, the latest Tensorflow install script seems to have a typo with some case mismatches in the variable names. I proposed a Pull Request to fix that & add Conda support (so you can install TF in your Miniforge Conda environment). I also provided instructions for how I installed both an ARM supported version of Miniforge/Conda Python and Tensorflow on it.

Feel free to manually apply my changes and see how it goes for you: #63

@jjbenes
Copy link

jjbenes commented Dec 13, 2020

@monikavila, as @tampapath suggested, you'll want to use python from Xcode. Once you install it, it should be at /Library/Developer/CommandLineTools/usr/bin/python3.
See here.

  1. Get the TF for M1 tarball from here.
  2. Install TF for M1 like this: /bin/bash tensorflow_macos/install_venv.sh -p --python=/Library/Developer/CommandLineTools/usr/bin/python3.
  3. Activate the virtual environment (. ~/tensorflow_macos/bin/activate if your environment is at ~/tensorflow_macos.) I have trouble with Conda and TF for M1, so I'm going to wait for Apple to fix it. (Your Conda setup is in ~/.bash_profile. You may want to turn it off. Price to pay as early adopters.)
  4. file $(which python)should return something like Mach-O universal binary with 2 architectures: [x86_64:Mach-O 64-bit executable x86_64] [arm64:Mach-O 64-bit executable arm64]. You do not want Mach-O 64-bit executable x86_64.

@jpulmano
Copy link

none of the above worked for me. I tried uninstalling the versions of python on my system (not the native ones), uninstalling x-code command line tools and reinstalling, but I continued to get a different error ("illegal hardware instruction")

however, I temporarily downgraded to tensorflow 1.5.0 (and used matching versions of keras, etc.) and the errors went away. if anyone figures out how to get rid of the illegal hardware instruction error, please reply!

@RajeshArasada
Copy link

None of the above worked for me. The kernel continues to break down when I try to import Tensorflow.

@MarkSenDong
Copy link

None of the above worked for me. The kernel continues to break down when I try to import Tensorflow.

Same here, I managed to install it into anaconda venv, but kernel keeps breaking down when I try to import Tensorflow.

@mwidjaja1
Copy link

You're using the word 'anaconda' -- remember that anaconda is not ARM compatible. You need to use the ARM version of miniforge (or some other ARMed version of Python). I personally used the ARM version of miniforge

@ratchfordc
Copy link

I've used conda mini-forge to install many packages for data work, to include numpy, pandas, matplotlib, jupyterlab3, seaborn, sqlalchemy, geopy, elementpath, google-cloud-bigquery, scikit-learn. This works so far but also brings python 3.9 along in my home directories. There's no need to uninstall anything. To create a venv I hunted down the version of python that installed from apple, 3.8.2. The tensorflow package won't install in a 3.9 venv.

Version 3.8 should be installed in /Library/Developer/CommandLineTools/usr/bin/python3

Create a virtual environment with 3.8:
/Library/Developer/CommandLineTools/usr/bin/python3 -m venv path_to_new_venv

Use this new environment when calling the install_venv.sh path_to_new_venv.

I now have two virtual environments for data work on the M1 Macbook, but I think it's feasible to save data from one to use in the other. This is an alpha version, so I think it's worth a little trouble to use the new Macbook, which is a fast and portable platform.

@jpulmano
Copy link

jpulmano commented Jan 21, 2021

I've used conda mini-forge to install many packages for data work, to include numpy, pandas, matplotlib, jupyterlab3, seaborn, sqlalchemy, geopy, elementpath, google-cloud-bigquery, scikit-learn. This works so far but also brings python 3.9 along in my home directories. There's no need to uninstall anything. To create a venv I hunted down the version of python that installed from apple, 3.8.2. The tensorflow package won't install in a 3.9 venv.

Version 3.8 should be installed in /Library/Developer/CommandLineTools/usr/bin/python3

Create a virtual environment with 3.8:
/Library/Developer/CommandLineTools/usr/bin/python3 -m venv path_to_new_venv

Use this new environment when calling the install_venv.sh path_to_new_venv.

I now have two virtual environments for data work on the M1 Macbook, but I think it's feasible to save data from one to use in the other. This is an alpha version, so I think it's worth a little trouble to use the new Macbook, which is a fast and portable platform.

sadly, this still does not work for me. here are the exact steps I followed:

  1. create virtual environment with 3.8: /Library/Developer/CommandLineTools/usr/bin/python3 -m venv new_env
  2. activate the virtual environment
  3. download and open tensorflow_macos-0.1alpha1.tar.gz
  4. run /bin/bash ./tensorflow_macos/install_venv.sh and specify the path to the new environment
  5. while the new environment is activated, try to run a python file with import tensorflow

this crashes, and gives me 82113 illegal hardware instruction

EDIT: Found a solution

my terminal was running with Rosetta :( I opened my terminal without rosetta, did the same exact steps outlined above, and everything worked.

woo!

@gupta-dipanshu
Copy link

I got Tensor Flow working on my Anaconda Spyder.

As I was a noob to these, so let me share my detailed findings for other people in similar boat.

First I downloaded: https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha0/tensorflow_macos-0.1alpha0.tar.gz

After unzipping, there is 2 folders inside arm64 and x86_64. The first reaction is for people to install arm64, since we have the Mac M1 chip. But actually since we wanted to install into Anaconda which runs through Rosetta2 as an Intel, we should install x86_64, which will run slower, but at least you have all the libraries such as pandas and support apps.

To Install x86_64 into Anaconda (so I can run in Spyder):

  1. Anaconda start a new environment
  2. Uninstall tensorflow & tensorboard if exists
  3. Rename all the files inside the x86_64 folder from 11_0 to 10_16. Example: tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl
  4. In Conda console run below with 'username' replaced with your username:
    pip install pip wheel setuptools cached-property six
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/grpcio-1.33.2-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/h5py-2.10.0-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/numpy-1.18.5-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/scipy-1.5.4-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl"

Source: #7 (comment)

** To Install arm64 into virtualenv **
This would give the fastest speed since it uses the native arm64, but it doesn't support many libraries at the moment, including pandas.

To install:

  1. With tensorflow_macos unzipped in the Downloads folder
  2. In Terminal: browse to Downloads folder
  3. Run: /bin/bash ./tensorflow_macos/install_venv.sh --prompt
  4. Key in your desired path or just Enter for the default path

To Run:

  1. In a new terminal run: source /Users/username/tensorflow_macos_venv/bin/activate
  2. python3 "your_python_file.py"

To toggle between CPU and GPU runs adjust the device_name below:
from tensorflow.python.compiler.mlcompute import mlcompute
mlcompute.set_mlc_device(device_name='gpu')

To make it faster, turn off the default Eager mode with the following line:
tf.compat.v1.disable_eager_execution()

Run Speed Comparison for MNIST character recognition:
Anaconda Spyder (x86_64, EagerOff): 200-256us/sample
Terminal (arm64, CPU, EagerOff): 22-63us/sample
Terminal (arm64, GPU, EagerOff): 137-166us/sample

Worked perfectly, thanks!

@tomuGo
Copy link

tomuGo commented Jan 23, 2021

same,i see some guy worked,they used miniconda,but i anaconda.is this?

@mwidjaja1
Copy link

@tomuGo Anaconda is not the same thing as Miniforge, Anaconda has not been compiled for ARM yet. Consider following the steps and making the changes proposed in !63 if you want a Conda Python install, or following the instructions in this issue to follow the officially supported Apple method.

@MaxKumundzhiev
Copy link

Additional tutorial which could help to setup TF within M1 approaching by miniforge here.

@gabirelasanchezzz
Copy link

I got Tensor Flow working on my Anaconda Spyder.

As I was a noob to these, so let me share my detailed findings for other people in similar boat.

First I downloaded: https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha0/tensorflow_macos-0.1alpha0.tar.gz

After unzipping, there is 2 folders inside arm64 and x86_64. The first reaction is for people to install arm64, since we have the Mac M1 chip. But actually since we wanted to install into Anaconda which runs through Rosetta2 as an Intel, we should install x86_64, which will run slower, but at least you have all the libraries such as pandas and support apps.

To Install x86_64 into Anaconda (so I can run in Spyder):

  1. Anaconda start a new environment
  2. Uninstall tensorflow & tensorboard if exists
  3. Rename all the files inside the x86_64 folder from 11_0 to 10_16. Example: tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl
  4. In Conda console run below with 'username' replaced with your username:
    pip install pip wheel setuptools cached-property six
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/grpcio-1.33.2-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/h5py-2.10.0-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/numpy-1.18.5-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/scipy-1.5.4-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl"

Source: #7 (comment)

** To Install arm64 into virtualenv **
This would give the fastest speed since it uses the native arm64, but it doesn't support many libraries at the moment, including pandas.

To install:

  1. With tensorflow_macos unzipped in the Downloads folder
  2. In Terminal: browse to Downloads folder
  3. Run: /bin/bash ./tensorflow_macos/install_venv.sh --prompt
  4. Key in your desired path or just Enter for the default path

To Run:

  1. In a new terminal run: source /Users/username/tensorflow_macos_venv/bin/activate
  2. python3 "your_python_file.py"

To toggle between CPU and GPU runs adjust the device_name below:
from tensorflow.python.compiler.mlcompute import mlcompute
mlcompute.set_mlc_device(device_name='gpu')

To make it faster, turn off the default Eager mode with the following line:
tf.compat.v1.disable_eager_execution()

Run Speed Comparison for MNIST character recognition:
Anaconda Spyder (x86_64, EagerOff): 200-256us/sample
Terminal (arm64, CPU, EagerOff): 22-63us/sample
Terminal (arm64, GPU, EagerOff): 137-166us/sample

Hi, it worked perfectly after days struggling. However I am a noob, and when I try to run it in Spyder it says

ModuleNotFoundError: No module named 'tensorflow'

But if I run:
pip list | grep tensorflow
it outputs:
tensorflow-estimator 2.4.0 Note: you may need to restart the kernel to use updated packages.

I have restarted the kernel but nothing will work. How could I solve this?

@mwidjaja1
Copy link

Any reason you aren't using the psuedo-official instructions that the Apple TensorFlow Team (and I, as a volunteer) wrote in Issue 153? #153.

Anaconda doesn't work on ARM64 -- it works in a compiled Rosetta x86 mode, but you will lose all the ARM optimizations then.

@monikavila
Copy link
Author

monikavila commented Mar 22, 2021

I got Tensor Flow working on my Anaconda Spyder.
As I was a noob to these, so let me share my detailed findings for other people in similar boat.
First I downloaded: https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha0/tensorflow_macos-0.1alpha0.tar.gz
After unzipping, there is 2 folders inside arm64 and x86_64. The first reaction is for people to install arm64, since we have the Mac M1 chip. But actually since we wanted to install into Anaconda which runs through Rosetta2 as an Intel, we should install x86_64, which will run slower, but at least you have all the libraries such as pandas and support apps.
To Install x86_64 into Anaconda (so I can run in Spyder):

  1. Anaconda start a new environment
  2. Uninstall tensorflow & tensorboard if exists
  3. Rename all the files inside the x86_64 folder from 11_0 to 10_16. Example: tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl
  4. In Conda console run below with 'username' replaced with your username:
    pip install pip wheel setuptools cached-property six
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/grpcio-1.33.2-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/h5py-2.10.0-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/numpy-1.18.5-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/scipy-1.5.4-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl"

Source: #7 (comment)
** To Install arm64 into virtualenv **
This would give the fastest speed since it uses the native arm64, but it doesn't support many libraries at the moment, including pandas.
To install:

  1. With tensorflow_macos unzipped in the Downloads folder
  2. In Terminal: browse to Downloads folder
  3. Run: /bin/bash ./tensorflow_macos/install_venv.sh --prompt
  4. Key in your desired path or just Enter for the default path

To Run:

  1. In a new terminal run: source /Users/username/tensorflow_macos_venv/bin/activate
  2. python3 "your_python_file.py"

To toggle between CPU and GPU runs adjust the device_name below:
from tensorflow.python.compiler.mlcompute import mlcompute
mlcompute.set_mlc_device(device_name='gpu')
To make it faster, turn off the default Eager mode with the following line:
tf.compat.v1.disable_eager_execution()
Run Speed Comparison for MNIST character recognition:
Anaconda Spyder (x86_64, EagerOff): 200-256us/sample
Terminal (arm64, CPU, EagerOff): 22-63us/sample
Terminal (arm64, GPU, EagerOff): 137-166us/sample

Hi, it worked perfectly after days struggling. However I am a noob, and when I try to run it in Spyder it says

ModuleNotFoundError: No module named 'tensorflow'

But if I run:
pip list | grep tensorflow
it outputs:
tensorflow-estimator 2.4.0 Note: you may need to restart the kernel to use updated packages.

I have restarted the kernel but nothing will work. How could I solve this?

My solution was to install all with coda mini forge.

Another option is to install Visual Code and they released a version that could run with ARM. But my problem is that sometimes (almost always) the kernel dies. That is something I could not solve yet.

@gabirelasanchezzz
Copy link

Any reason you aren't using the psuedo-official instructions that the Apple TensorFlow Team (and I, as a volunteer) wrote in Issue 153? #153.

Anaconda doesn't work on ARM64 -- it works in a compiled Rosetta x86 mode, but you will lose all the ARM optimizations then.

Hi, so I have as well tried but I get the following error after I run step 3:
environment variables: CIO_TEST=<not set> CONDA_AUTO_UPDATE_CONDA=false CONDA_DEFAULT_ENV=base ...

@mwidjaja1
Copy link

@gabirelasanchezzz And you are sure you ran the 'Sanity Check' steps in the 'Install Miniforge' section and all of them looked right, pointing to miniforge? It really sounds like you did not install Miniforge correctly.

@gabirelasanchezzz
Copy link

gabirelasanchezzz commented Mar 22, 2021

@mwidjaja1 I have done all the steps, but I realized my after doing the sanity check I get:
/.../anaconda3/bin/python: Mach-O 64-bit executable x86_64
Despite I have an M1 Mac. I have removed Miniforge and reinstalled it ensuring it is the one for arm64 architecture but still outputs the same 😭

@mwidjaja1
Copy link

@gabirelasanchezzz I think you must have confused your Mac to what's going on because the guide doesn't tell you to install Anaconda and yet you have it. I dunno how much any of us can help you at this point to be honest -- this seems like a configuration issue for your Mac specifically now.

My best advice is to find your .bashrc/.zshrc file (depending on what you store all your environment variables in), delete anything related to anaconda/miniforge, delete anaconda/miniforge from your computer completely, and start again. Short of that, there's not much I think we can help you with short of starting completely from fresh.

@gabirelasanchezzz
Copy link

@mwidjaja1 I see. I am new here so I think I just messed the configuration. Thanks for trying to help, really!

@mwidjaja1
Copy link

@gabirelasanchezzz yeah sorry 😔. I just am out of ideas on how to help you remotely unfortunately. But yeah my best advice is do your darnest to start from fresh again in regards to your terminal environment and uninstalling everything but the system Python and starting from fresh. Or create a new user account on your Mac and try setting it up there, just so at least you have an 'answer key' you can compare your currrent user account with to see where you might have went wrong.

Best of luck!

@gabirelasanchezzz
Copy link

@mwidjaja1 Oh I had not thought about the user. Thanks a lot!

@leoloman
Copy link

leoloman commented Apr 2, 2021

@jrlindell

**Dont create new Virtual Environment under Anaconda. You have to create it under Miniforge **

First, get out of the anaconda env , and after you download the miniforge create the Virtual Environment under Miniforge .

Screenshot 2021-03-06 at 10 56 16 AM

Once you create Env in Miniforge this will come . So Don't Close this terminal yet. open a new terminal
Screenshot 2021-03-06 at 11 11 31 AM

Download Additional file

Screenshot 2021-03-06 at 11 05 51 AM

Downloading the Tensorflow : Download tensorflow from releases , Once you download and unzip it open the file and drag - drop install_venv into terminal under the env also add -p in the end. it will ask for the location . provide the same location as the env.

Screenshot 2021-03-06 at 11 15 16 AM

There You go . Tensorflow is working for me perfectly on m1 even in jupyter notebook too

Screenshot 2021-03-06 at 11 19 37 AM

This worked perfectly for me if anyone is having trouble and has the mini forge arm installed

@testforme0
Copy link

also struggles with

Do you remember what changes were made, I also encountered the same problem?

@gabirelasanchezzz
Copy link

also struggles with

Do you remember what changes were made, I also encountered the same problem?

Hi, I desisted. All I tried did not work. However, I have not tried yet the solution of @leoloman . I definitely need to try this. Best of luck

@testforme0
Copy link

also struggles with

Do you remember what changes were made, I also encountered the same problem?

Hi, I desisted. All I tried did not work. However, I have not tried yet the solution of @leoloman . I definitely need to try this. Best of luck

I use bash instead of zsh, command success!I dont know why,but it works

@may3rd
Copy link

may3rd commented Apr 11, 2021

Has anyone successfully install object detection on python?
I've tried without any luck. There is too much error and warning.

Any hint?

@arjanvanham
Copy link

I followed the Clayton Pilat's instructions from here and got everything installed that I was struggling with for weeks:

% python
Python 3.8.8 | packaged by conda-forge | (default, Feb 20 2021, 15:50:57) 
[Clang 11.0.1 ] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
>>> import PIL
>>> import matplotlib
>>> import keras
>>> 

Apple MacBook Pro M1 / Big Sur 11.2.3, Python 3.8.8

@VeronicaCPerez
Copy link

I am trying to install tensor flow in the new MacBook Pro M1 but it gives the error
ERROR: numpy-1.18.5-cp38-cp38-macosx_11_0_arm64.whl is not a supported wheel on this platform.

@monikavila I fixed it by downgrading my python from 3.9.1 to 3.8.6

@denalist
Copy link

I got Tensor Flow working on my Anaconda Spyder.

As I was a noob to these, so let me share my detailed findings for other people in similar boat.

First I downloaded: https://github.com/apple/tensorflow_macos/releases/download/v0.1alpha0/tensorflow_macos-0.1alpha0.tar.gz

After unzipping, there is 2 folders inside arm64 and x86_64. The first reaction is for people to install arm64, since we have the Mac M1 chip. But actually since we wanted to install into Anaconda which runs through Rosetta2 as an Intel, we should install x86_64, which will run slower, but at least you have all the libraries such as pandas and support apps.

To Install x86_64 into Anaconda (so I can run in Spyder):

  1. Anaconda start a new environment
  2. Uninstall tensorflow & tensorboard if exists
  3. Rename all the files inside the x86_64 folder from 11_0 to 10_16. Example: tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl
  4. In Conda console run below with 'username' replaced with your username:
    pip install pip wheel setuptools cached-property six
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/grpcio-1.33.2-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/h5py-2.10.0-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/numpy-1.18.5-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/scipy-1.5.4-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_addons-0.11.2+mlcompute-cp38-cp38-macosx_10_16_x86_64.whl"
    pip install absl-py astunparse flatbuffers gast google_pasta keras_preprocessing opt_einsum protobuf tensorflow_estimator termcolor typing_extensions wrapt wheel tensorboard typeguard
    pip install "/Users/username/Downloads/tensorflow_macos/x86_64/tensorflow_macos-0.1a0-cp38-cp38-macosx_10_16_x86_64.whl"

Source: #7 (comment)

** To Install arm64 into virtualenv **
This would give the fastest speed since it uses the native arm64, but it doesn't support many libraries at the moment, including pandas.

To install:

  1. With tensorflow_macos unzipped in the Downloads folder
  2. In Terminal: browse to Downloads folder
  3. Run: /bin/bash ./tensorflow_macos/install_venv.sh --prompt
  4. Key in your desired path or just Enter for the default path

To Run:

  1. In a new terminal run: source /Users/username/tensorflow_macos_venv/bin/activate
  2. python3 "your_python_file.py"

To toggle between CPU and GPU runs adjust the device_name below:
from tensorflow.python.compiler.mlcompute import mlcompute
mlcompute.set_mlc_device(device_name='gpu')

To make it faster, turn off the default Eager mode with the following line:
tf.compat.v1.disable_eager_execution()

Run Speed Comparison for MNIST character recognition:
Anaconda Spyder (x86_64, EagerOff): 200-256us/sample
Terminal (arm64, CPU, EagerOff): 22-63us/sample
Terminal (arm64, GPU, EagerOff): 137-166us/sample

Tried so many online tutorials to install, finally found a one worked !

@gabirelasanchezzz
Copy link

4. pip install "/Users/username/Downloads/tensorflow_macos/x86_64/h5py-2.10.0-cp38-cp38-macosx_10_16_x86_64.whl"

Hi, sorry this does not work for me either. The next error pops up:

ERROR: grpcio-1.33.2-cp38-cp38-macosx_10_16_x86_64.whl is not a supported wheel on this platform.

@mwidjaja1
Copy link

@gabirelasanchezzz You're using an Intel wheel file but this thread is for M1 computers.

@gabirelasanchezzz
Copy link

@mwidjaja1 I do have an M1. I just was following the instructions @denalist provided.

@mwidjaja1
Copy link

Ahh gotcha. Yeah I'm not sure how to help you then. The route @denalist took, while legitimate for sure, does not use a native M1 Python. It uses Rosetta to build an Intel version of Python, for M1. Upside, installation should be easier and the entire world of pip + conda is at your fingertips. Downside, you won't get any of the m1 Processor + GPU efficiencies, and then situations like these. My guess is your Mac is confused between using the M1 version of Python it came with vs. the intel version you tried to download.

I did write my own tutorial for M1 Python + TensorFlow at #153 but I confess, it does get a little bit tricky because it is a strange scenario. In that path you would get the M1 optimizations but not every package will work, though most of the 'popular' packages like Numpy/Scipy would work.

@denalist
Copy link

@gabirelasanchezzz Please read it before making the conclusion, I didnt provide the solution. and the thread is clear enough says "M1".

@gabirelasanchezzz
Copy link

@mwidjaja1 I just went to your tutorial and started following the steps. When I eventually reached: "file $(which python)" in the terminal, Mach-O 64-bit executable x86_64 appears, but I do have an M1, so as you said, my Mac is confused. Do you know any way to fix this??

@mwidjaja1
Copy link

Does which python direct you to the miniforge3 version of Python or some other path?

@gabirelasanchezzz
Copy link

it directs me to /opt/anaconda3/bin/python

@mwidjaja1
Copy link

Please follow that section because it tells you the appropriate steps to redirect your Python to miniforge3. The guide has a lot of words but that's because I know there are a lot of ways things can go wrong. The paragraph you should have followed that'd fix that is:

If you did all that, set your environment paths to Miniforge's Python Installation. To do that, you need to figure out where conda was installed to (it's probably ~/miniforge3/condabin/conda) and then run ~/miniforge3/condabin/conda init in your terminal.

@vivek9patel
Copy link

Hey guys,
For me, it was a python version error.
I was using python=3.9.5 (latest) version, and the wheel file is supported in 3.8.* version as the file name (cp38) says.
So I solved it using conda install python=3.8.5 in my conda environment.
And it works fine!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests