tensorflow: Apple M1 chip - illegal hardware instruction

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): MacOS Big Sur 11.0.1
  • TensorFlow installed from (source or binary): https://www.tensorflow.org/install/pip
  • TensorFlow version: Latest stable (pip)
  • Python version: Python 3.8.5
  • Installed using virtualenv? pip? conda?: exactly like in the instruction https://www.tensorflow.org/install/pip
  • Bazel version (if compiling from source): /
  • GCC/Compiler version (if compiling from source): /
  • CUDA/cuDNN version: /
  • GPU model and memory: /

Describe the problem

After running the verification steps

python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

The following error appear

illegal hardware instruction

Any other info / logs This issue only appear on the Mac with the Apple M1 chip. The same setup procedure https://www.tensorflow.org/install/pip works fine on my other Mac`s.

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 16
  • Comments: 23 (2 by maintainers)

Most upvoted comments

We don’t support the M1 chip. This comes from an Apple fork.

I am M1 Pro user. I met this problem after activating the virtual environment Anaconda and installing tensorflow. When I run my program and it failed. I’m perplexed about it and hope that Tim Cook can help me.

Hello Mihai,

thanks for your quick response. This information rather surprises me especially since Apple and TensorFlow did quite some advertising about it.

  • This means we will have to work on some kind of private Apple fork rather then on the official TensorFlow version?
  • Are there any plans to integrate this directly into TensorFlow?
  • This also means we are bounded to TensorFlow 2.4 on Apple M1 Macs?

It seems somehow odd to use a fork just because it is another chip.

Is there any update on this issue? Now it is June 12th and I’m still getting this error.

on your terminal simply type: conda create -n tf tensorflow here rename tf to the name of your choice

For Rosetta2: see #46044 (master branch should be able to compile, 2.4 branch waiting for a patch release) For M1 chip, we landed #45404 so now if you compile this repo from source you should also get a working TF.

We are currently looking at how we can provide ongoing support.

I think we can close this now and leave #46044 open.

In the near future, we’ll be making updates like this even easier for users 
to get these performance numbers by integrating the forked version into
the TensorFlow master branch.

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

Can you provide us an ETA for that?

Great to see the community is working on that https://github.com/tensorflow/tensorflow/pull/45404. But it usually takes a lot of time till builds are implemented and integrated. That means I have to rely on Apple and their support. This is a big issue in my opinion.

You guys must see this post https://developer.apple.com/metal/tensorflow-plugin/

this post describes how to import TensorFlow with there plugins

Facing a similar issue created a new environment and installed all the required packages using conda-mini forge. Now the issue I’m getting is below.

(TeleStoke) rish@DSIs-MBP Server % python app.py zsh: illegal hardware instruction python app.py

I am M1 Pro user. I met this problem after activating the virtual environment Anaconda and installing tensorflow. When I run my program and it failed. I’m perplexed about it and hope that Tim Cook can help me.

https://docs.anaconda.com/anaconda/user-guide/tasks/tensorflow/

try out the first method of installing tensorflow. It worked for my M1 Macbook Pro

on your terminal simply type: conda create -n tf tensorflow here rename tf to the name of your choice

Hi @rish2497 !

I could run scripts through "python app.py" but it is not giving output as expected compared to linux and windows.

We are bringing this to internal team again. Thanks for bringing it up again.

Thank you!

Afaik Apple has not communicated at all with the team that does the releases. Given that there is only 1 person (actually less since releases are not prioritized), there cannot be an ETA.