I run some issues with tensorflow and M1 Mac too. I think this will help:
Install anaconda for silicon macs (you already have this)
Download this yml file yml file You can change the python verson in the yml file to your specific python version.
Run this command to create a new enviroment for tensorflow in the path where you installed the yml file:
conda env create -f tensorflow-apple-metal.yml -n tensorflow
- Connect to the new enviroment:
conda activate tensorflow
- Add this enviroment to the jupyter list:
python -m ipykernel install --user --name tensorflow --display-name "Python 3.10 (tensorflow)"
If you get an error here just install the ipykernel first
conda install ipykernel
- Finnaly test it in Jupyter.
Run:
jupyter notebook
Now uou can chek if the GPU is working using this lines of code:
import sys
import tensorflow.keras
import pandas as pd
import sklearn as sk
import tensorflow as tf
import platform
print(f"Python Platform: {platform.platform()}")
print(f"Tensor Flow Version: {tf.__version__}")
print(f"Keras Version: {tensorflow.keras.__version__}")
print()
print(f"Python {sys.version}")
print(f"Pandas {pd.__version__}")
print(f"Scikit-Learn {sk.__version__}")
gpu = len(tf.config.list_physical_devices('GPU'))>0
print("GPU is", "available" if gpu else "NOT AVAILABLE")
You can check and follow all this steps in this repository:
tensorflow-metal repo
Hope it works for you.