简体   繁体   English

在 macOS M1 上安装 tensorflow

[英]Installing tensorflow on macos M1

I have a 2020 MacBook Air M1-chip with MacOS 12.2 Monterey.我有一台装有 MacOS 12.2 Monterey 的 2020 MacBook Air M1 芯片。 I have for the past several months tried pretty much everything to get tensorflow to work, but nothing seems to work.在过去的几个月里,我几乎尝试了所有方法来让 tensorflow 正常工作,但似乎没有任何效果。 I tried with conda environments, tried installing tensorflow-deps, but I always got this error message:我尝试使用 conda 环境,尝试安装 tensorflow-deps,但我总是收到此错误消息:

(python_main) MacBook-Air-2:python_main martinwestin$ conda install -c apple tensorflow-deps

Collecting package metadata (current_repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): done
Solving environment: failed with initial frozen solve. Retrying with flexible solve.

PackagesNotFoundError: The following packages are not available from current channels:

  - tensorflow-deps

Current channels:

  - https://conda.anaconda.org/apple/osx-64
  - https://conda.anaconda.org/apple/noarch
  - https://repo.anaconda.com/pkgs/main/osx-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/osx-64
  - https://repo.anaconda.com/pkgs/r/noarch
  - https://conda.anaconda.org/conda-forge/osx-64
  - https://conda.anaconda.org/conda-forge/noarch

To search for alternate channels that may provide the conda package you're
looking for, navigate to

    https://anaconda.org

and use the search bar at the top of the page.

And if I pip install tensorflow and try to import it, I always get the error message:如果我 pip 安装 tensorflow 并尝试导入它,我总是会收到错误消息:

Illegal instruction: 4

Does anyone have any ideas how this can be fixed, as I bought this computer for its advantages in training ML models...有没有人知道如何解决这个问题,因为我购买这台计算机是因为它在训练 ML 模型方面具有优势......

this is maybe due to the fact that TensorFlow is not yet compatible with the Apple M1 chip.这可能是因为 TensorFlow 还不兼容 Apple M1 芯片。 TensorFlow does not yet have official support for the M1 chip, and the current version of TensorFlow that is available for installation via pip is built for the x86 architecture TensorFlow 还没有对 M1 芯片的官方支持,可以通过 pip 安装的当前版本的 TensorFlow 是为 x86 架构构建的

You can try installing tensorflow with pip but with the flag pip install tensorflow --no-binary:all:您可以尝试使用 pip 安装 tensorflow,但使用标志pip install tensorflow --no-binary:all:

or you can use alternate method或者你可以使用替代方法

you can try using other libraries such as PyTorch or Jax that are compatible with M1 chip.您可以尝试使用其他与 M1 芯片兼容的库,例如 PyTorch 或 Jax。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM