Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
473 views
in Technique[技术] by (71.8m points)

python 3.x - python3 install of Tensorflow on Apple silicon M1

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)]

enter image description here

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

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...