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.

Revisions

  1. tarun-ssharma created this gist Aug 1, 2023.
    52 changes: 52 additions & 0 deletions tensorflow-macos-bigsur.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,52 @@
    **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`
    4. conda config --add channels conda-forge
    5. conda config --set channel_priority strict
    6. conda create -y --name cv
    7. conda activate cv
    8. conda install -y -c apple tensorflow-deps==2.10.0
    9. python --version
    `Python 3.10.12`
    10. python -m pip install tensorflow-macos==2.9.2
    11. 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)`
    12. python -m pip install tensorflow-metal==0.5.0
    13. 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`
    14. python -m pip install jupyter
    15. python -m pip install ipykernel
    16. python -m ipykernel install --user --name cv --display-name "Python3.10 (cv)"
    17. jupyter notebook
    `Inside notebook, import tensorflow fails`
    18. python -m pip uninstall tensorflow-macos tensorflow-metal tensorflow
    19. conda deactivate
    20. python -m pip install --user tensorflow-metal tensorflow-macos
    21. 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.