Martin Westin
Martin Westin

Reputation: 175

Installing tensorflow on macos M1

I have a 2020 MacBook Air M1-chip with MacOS 12.2 Monterey. I have for the past several months tried pretty much everything to get tensorflow to work, but nothing seems to work. I tried with conda environments, tried installing tensorflow-deps, but I always got this error message:

(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:

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...

Upvotes: 2

Views: 703

Answers (1)

Smarty
Smarty

Reputation: 813

this is maybe due to the fact that TensorFlow is not yet compatible with the Apple M1 chip. 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

You can try installing tensorflow with pip but with the flag 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.

Upvotes: 0

Related Questions