I am always trying to minimize disk consumption, so when looking to install tensorflow, it really matters how you've bundled virtual envs to service more than project. I've got a good bundle going with a localGPT virtual env. Using miniconda and running Python 3.10, this localGPT venv is wired for localGPT, TensorFlow dependencies, and Melodia generative AI. conda commands you may like to know:
conda env listconda create -n env-name python=3.10conda activate env-name
Step 1: Installing Xcode Command Line Tools
xcode-select --install
Step 2: Installing Anaconda for M Chip Download Anaconda for M Chip: https://www.anaconda.com/download, miniconda also works, and saves about a gig of disk.
Step 3: Installing TensorFlow Dependencies
conda install -c apple tensorflow-deps
Step 4: Creating a Conda Environment
conda create -n tensorflow python=3.10
Step 5: Installing TensorFlow and Plugins
pip install tensorflow-macos tensorflow-metal
Step 6: Installing Additional Packages (Customization)
conda install numpy pandas matplotlib scikit-learn scipy plotly jupyter
Step 7: Troubleshooting Tips
Step 8: Verifying TensorFlow Installation:
import sys
import tensorflow.keras
import pandas as pd
import sklearn as sk
import scipy as sp
import tensorflow as tf
# import keras
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__}")
print(f"SciPy {sp.__version__}")
gpu = len(tf.config.list_physical_devices ('GPU'))>0
print("GPU is", "available" if gpu else "NOT AVAILABLE" )