Skip to content

Instantly share code, notes, and snippets.

@tarun-ssharma
Created August 1, 2023 04:51
Show Gist options
  • Save tarun-ssharma/4cb54e6212d0bb2f4b2cb2666f11d1d8 to your computer and use it in GitHub Desktop.
Save tarun-ssharma/4cb54e6212d0bb2f4b2cb2666f11d1d8 to your computer and use it in GitHub Desktop.
Installing tensorflow on macOS Big Sur

TL;DR: Couldn't get Tensorflow to work with MacOS BigSur

First, I tried these commands, with python 3.10:

  1. Install Miniconda from their website
  2. conda install -c apple tensorflow-deps Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort. failed
  3. conda config --add channels conda-forge
  4. conda config --set channel_priority strict
  5. conda create -y --name cv
  6. conda activate cv
  7. conda install -y -c apple tensorflow-deps==2.10.0
  8. python --version Python 3.10.12
  9. python -m pip install tensorflow-macos==2.9.2
  10. python -m pip install tensorflow-metal==0.5.1 ERROR: Could not find a version that satisfies the requirement tensorflow-metal==0.5.1 (from versions: 0.5.0)
  11. python -m pip install tensorflow-metal==0.5.0
  12. conda list|grep -E '(tensorflow|numpy)' numpy 1.23.2 py310h127c7cf_0 conda-forge tensorflow-deps 2.10.0 0 apple tensorflow-estimator 2.9.0 pypi_0 pypi tensorflow-macos 2.9.2 pypi_0 pypi tensorflow-metal 0.5.0 pypi_0 pypi
  13. python -m pip install jupyter
  14. python -m pip install ipykernel
  15. python -m ipykernel install --user --name cv --display-name "Python3.10 (cv)"
  16. jupyter notebook Inside notebook, import tensorflow fails
  17. python -m pip uninstall tensorflow-macos tensorflow-metal tensorflow
  18. conda deactivate
  19. python -m pip install --user tensorflow-metal tensorflow-macos
  20. python >> import tensorflow as tf Fails again

So I got frustrated and tried these instead in a new shell:

  1. conda create --name tensorflow_m1 python==3.9
  2. conda activate tensorflow_m1
  3. conda install -c apple tensorflow-deps==2.8
  4. pip -V pip 23.2.1 from /Users/starun/miniconda3/envs/tensorflow_m1/lib/python3.9/site-packages/pip (python 3.9)
  5. python -V Python 3.9.0
  6. pip install tensorflow-macos==2.8
  7. pip install tensorflow-metal==0.4.0
  8. conda install ipykernel
  9. ipython kernel install --name tensorflow_m1 --user
  10. jupyter notebook In the notebook, tensorflow import still fails

Then I noticed that tensorflow-metal only works with MacOS >= 12.0 so I'll create a separate gist with the latest MacOS version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment