python3 install of Tensorflow on Apple silicon M1

ぃ、小莉子 提交于 2021-02-05 08:00:06

问题


I have macOS Big Sur on a Apple Silicon M1 and I'm unable to install Tensorflow in python3. I removed xcode python3 and installed brew arm64 python3 (x86 python3 doesn't work as well)

I checked successful 64 bis version

python3 -c "import sys; print(sys.version)" or python -c "import struct; print(struct.calcsize('P')*8)"

3.8.7 (default, Dec 30 2020, 02:09:32) [Clang 12.0.0 (clang-1200.0.32.28)]

Can this work anyhow, or who knows, how to make this work ?


回答1:


Apple M1 is a processor with an ARM64 architecture, while all pip packages of TensorFlow are compiled for the x86_64 architecture. (excluding the raspberry pi packages, but they would not be compatible with MacOs anyway).

If we look at the name of the pip packages on the install page of TensorFlow, most of them contains either x86_64 or amd64, that indicates that they are built against the x86_64 architecture.

If you want to run TensorFlow on the M1, you either need to:

  • compile TensorFlow from sources targeting x86_64 through Rosetta 2. Unfortunately, according to this issue on github, Rosetta 2 does not support the AVX instruction set which are enabled in the pip builds of TensorFlow, so rebuilding from source is needed.
  • Use the experimental support for TensorFlow on M1 developed by Apple, that you can find on this github repository. Note that, if going that way, some python packages might not be compatible/available with the M1.

Note that as of 2021/01/04, the Apple M1 is not a supported architecture by the TensorFlow team:

We currently cannot support Mac ARM. There is less than one developer than can focus on build issues on all 3 operating systems.

Hence, support has to come from the the community. There is SIG Build that focuses on build related issues on several other platforms, leaving us to only focus on the pip packages we officially bless.



来源:https://stackoverflow.com/questions/65770132/python3-install-of-tensorflow-on-apple-silicon-m1

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!