TL;DR: Couldn't get Tensorflow to work with MacOS BigSur
First, I tried these commands, with python 3.10:
- Install Miniconda from their website
- conda install -c apple tensorflow-deps
Found conflicts! Looking for incompatible packages. This can take several minutes. Press CTRL-C to abort. failed
- conda config --add channels conda-forge
- conda config --set channel_priority strict
- conda create -y --name cv
- conda activate cv
- conda install -y -c apple tensorflow-deps==2.10.0
- python --version
Python 3.10.12
- python -m pip install tensorflow-macos==2.9.2
- 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)
- python -m pip install tensorflow-metal==0.5.0
- 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
- python -m pip install jupyter
- python -m pip install ipykernel
- python -m ipykernel install --user --name cv --display-name "Python3.10 (cv)"
- jupyter notebook
Inside notebook, import tensorflow fails
- python -m pip uninstall tensorflow-macos tensorflow-metal tensorflow
- conda deactivate
- python -m pip install --user tensorflow-metal tensorflow-macos
- python >> import tensorflow as tf
Fails again
So I got frustrated and tried these instead in a new shell:
- conda create --name tensorflow_m1 python==3.9
- conda activate tensorflow_m1
- conda install -c apple tensorflow-deps==2.8
- pip -V
pip 23.2.1 from /Users/starun/miniconda3/envs/tensorflow_m1/lib/python3.9/site-packages/pip (python 3.9)
- python -V
Python 3.9.0
- pip install tensorflow-macos==2.8
- pip install tensorflow-metal==0.4.0
- conda install ipykernel
- ipython kernel install --name tensorflow_m1 --user
- 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.