Kev*_*Kev 3 python rosetta tensorflow apple-m1
我正在努力使用 M1 mac 安装 TensorFlow。我有 python 3.9.7 和 Monterrey 12.3 以及 Apple Silicon Visual Studio 代码。有一个苹果解决方案,涉及 miniconda 苹果依赖项、tensorflow-macos 和 tensorflow-metal。然而这个解决方案对我来说并不好,因为我必须使用 Rosetta2 模拟器来运行多个软件包,包括 PyQt5 等。我想知道是否有人能够在 venv Rosetta 终端中使用他们的 M1 mac 和 pip 安装的张量流。谢谢。
凯文
TensorFlow 可以在 M1 (arm64) mac 上本机运行。强烈推荐在 arm64 Mac 上安装 TensorFlow 的简单方法是通过 conda-forge。您应该通过miniforge或miniconda安装 python ,因为有一个 arm64 (Apple Sillicon) 发行版。有了这个,从今天开始,您可以安装最新版本的 TensorFlow 2.10.0:
$ lipo -archs $(which python3) # python3 is running natively as arm64
arm64
$ conda install -c conda-forge tensorflow
Run Code Online (Sandbox Code Playgroud)
注意:tensorflow-macos2.4.0 已过时,因此您不应该使用它。
如果您确实需要在某些软件包不支持 arm64 的情况下在 Rosetta 2 (x86_64) 上运行 python ,您仍然可以通过 conda 安装带有 macOS x86_64 版本的 TensorFlow。通过 PyPI 存储库安装pip在这里不起作用,因为您将遇到Illegal hardware instruction段错误,因为 PyPI 上的 Google 官方 TF macos-x86_64 轮版本假定目标平台具有 AVX 指令。
$ lipo -archs $(which python3) # x86_64 means Rosetta 2
x86_64
$ conda install -c conda-forge tensorflow # install via conda
$ python -c 'import tensorflow; print(tensorflow.__version__)'
Run Code Online (Sandbox Code Playgroud)