How to Install Tensorflow Keras GPU for Mac M1/M2 with Conda
If you have a Mac with an M1 or M2 chip and want to take advantage of the GPU capabilities for running Tensorflow Keras, using Conda is the recommended way to install everything you need. Follow these steps to set up your environment and get Tensorflow Keras running on your Mac.
Step 1: Install Miniforge
Miniforge is a Conda distribution that is optimized for M1/M2 chips. First, download and install Miniforge from the official website. Make sure to select the appropriate version for your architecture.
Step 2: Create a Conda Environment
Once Miniforge is installed, open a terminal and create a new Conda environment for your Tensorflow Keras setup. You can do this by running the following command:
conda create -n tf-gpu python=3.8
This will create a new Conda environment called tf-gpu with Python 3.8 as the default Python version.
Step 3: Activate the Environment
Once the environment is created, you can activate it using the following command:
conda activate tf-gpu
Step 4: Install Tensorflow and Keras
Now that the environment is activated, you can install Tensorflow and Keras with GPU support using the following command:
conda install -c anaconda tensorflow-gpu keras-gpu
This will install the necessary packages for Tensorflow and Keras with GPU support in your Conda environment.
Step 5: Test the Installation
To ensure everything is working correctly, you can run a simple test script that uses Tensorflow Keras with GPU support. Create a new Python script with the following contents and run it:
import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))
If everything is set up correctly, you should see output indicating that a GPU device is available for use with Tensorflow Keras.
Conclusion
By following these steps, you can install Tensorflow Keras with GPU support on your Mac with an M1/M2 chip using Conda. This will enable you to take advantage of the GPU capabilities for training and running deep learning models, providing a significant performance boost for your machine learning tasks.
THANK YOU SIR!
Hi, I keep getting this error when running the last part:
#print(f"Keras Version: {tensorflow.keras.__version__}")
AttributeError: module 'tensorflow.keras' has no attribute '__version__'
for those who can't find the yml file I just copy paste from the video – open a new file in a text editor. save below content as tools.yml
the rest is the same. it installs the latest versions except python, a thing to consider.
channels:
– apple
– conda-forge
dependencies:
– python=3.10
– pip>=19.0
– jupyter
– scikit-learn
– scipy
– pandas
– pandas-datareader
– matplotlib
– pillow
– tqdm
– requests
– h5py
– pyyaml
– flask
– boto3
– ipykernel
– pip:
– tensorflow-macos
– tensorflow-metal
– bayesian-optimization
– gym
– kaggle
Thank you for this useful video! However, the page to the yaml is not found so I couldn't download it.
Thank you for sharing your experience. I've encountered an issue where, despite installing TensorFlow GPU, the model compiles using only the CPU without any notification that it's utilizing the GPU. If anyone has faced this problem and discovered a solution, I would greatly appreciate it if you could share it with me.
anyone know how much storarge this whole installation will take?
Hi there! unfortunately the YAML file is no longer in your repo
If y’all was smart yall would just screenshot the command in the video. The link was for the commands. That are already in the vid
no file available
link not working either
https://raw.githubusercontent.com/jeffheaton/t81_558_deep_learning/master/tensorflow-apple-metal.yml
I cant find the yml file😊
This .yml file is not available in the given git branch, even not the whole repo
I tried to get hold of the yaml file – the link no longer works.
Thank you very much for this video. It helped me a lot.
The git links are broken
tools.yml' file not found, how to solve this problem? I'm still struggling😭
The github link is not active
I followed your instructions, but I am getting GPU is NOT AVAILABLE … ?
The Github links above say "not found"
There is no repository as of now in your github link. I installed it a year ago using your previous tutorial which worked like a charm before but now i just cannot do it. I tried everything and I am in the arm's version only ( I tried reinstalling everything, creating new environment, working on main environment, i even from the video made that yml file which worked on terminal but doesn't work in my notebook it just doesn't) and i need my mac's gpu for sure for the project i am working on. If anyone can help me it would be a big help.
and my error is as follows
dlopen(/Users/my_file_path/lib/python3.10/site-packages/tensorflow-plugins/libmetal_plugin.dylib, 0x0006): symbol not found in flat namespace '__ZN10tensorflow8internal10LogMessage16VmoduleActivatedEPKci'
There is a 404 Not found error in the link you gave