'tensorflow crashes on Mac M1

I am trying to start using tensorflow on my M1 Mac. However, I only get the following message when I try to import tensorflow

Python 3.8.5 (v3.8.5:580fbb018f, Jul 20 2020, 12:11:27) 
[Clang 6.0 (clang-600.0.57)] on darwin
In [2]: import tensorflow as tf


Process finished with exit code 132 (interrupted by signal 4: SIGILL)

I have tried using tensorflow versions 2.7.0, 2.6.0 and 2.5.0 but all have the same problem.



Solution 1:[1]

I don't believe that M1 support is merged into mainline TF yet. You need to pip install Apple's special forks and packages, including (but not only) the following.

tensorflow-macos
tensorflow-metal
tensorflow-deps
tensorflow-macos

The full instructions are here, and that's where I'd start.

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

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Yaoshiang