Setup Mac for Machine Learning with TensorFlow in 13 minutes (works for all M1, M2)
Ғылым және технология
Setup your Apple M1 or M2 (Normal, Pro, Max or Ultra) Mac for data science and machine learning with TensorFlow.
In this video, we install Homebrew and Miniforge3 to create a Conda environment containing pandas, NumPy, Scikit-Learn, Matplotlib, Jupyter and TensorFlow.
We'll also setup TensorFlow to leverage the GPU on the new M1 chips.
Step by step instructions - github.com/mrdbourke/m1-machi...
See M1 machine learning speed test benchmarks - • Apple's M1 Pro and M1 ...
Setup Apple Silicon Mac with PyTorch - • Setup Mac for Machine ...
Links:
Learn ML (beginner-friendly courses I teach) - www.mrdbourke.com/ml-courses/
ML courses/books I recommend - www.mrdbourke.com/ml-resources/
Read my novel Charlie Walks - www.charliewalks.com
Connect elsewhere:
Web - dbourke.link/web
Twitter - / mrdbourke
Twitch - / mrdbourke
ArXiv channel (past streams) - dbourke.link/archive-channel
Get email updates on my work - dbourke.link/newsletter
Timestamps:
0:00 - Intro
0:30 - What we're covering
1:00 - All resources are on GitHub
1:25 - Downloading and installing Homebrew
2:45 - Downloading and installing Miniforge3
4:25 - Restart terminal for changes to take effect
4:57 - Creating a directory to test out TensorFlow
5:30 - Creating a Conda environment for machine learning experiments
7:12 - Installing TensorFlow dependencies for Mac from Apple's Conda channel
8:40 - Installing tensorflow-macos
9:15 - Installing tensorflow-metal so you can run TensorFlow on your Mac's GPU
10:30 - Installing tensorflow-datasets (optional)
10:50 - Installing standard data science packages (Jupyter, NumPy, pandas, Matplotlib, Sklearn)
11:15 - Starting a Jupyter Notebook
11:40 - Testing importing different libraries and seeing if TensorFlow has GPU access
#MachineLearning #MacBookPro
Пікірлер: 339
Thank you Daniel! I bought the M1 MBP so that I could learn and experiment. Successfully installed and tested TensorFlow-metal. Enrolled in your TemsorFlow Developer Certificate course. Great course, great explanations of concepts and exercises!
This is the best environment setup tutorial I've ever seen. I just got my personal MacBook Air M1 ~30 min ago and I'm already up and running with TF on the GPU. Well done, sir!
@mrdbourke
2 жыл бұрын
Thank you Daniel! Enjoy!
@MrPanda-gf6iu
2 жыл бұрын
I wish I discovered this earlier, I wasted all day trying to setup a docker.
@yvankoabiloa9490
Жыл бұрын
@@mrdbourke when I try to use my apple gpu with pytorch on jupyter notebook, it said that my kernel died. How can I make my kernel works without this thing happen? PS: I try to use a transformer model to train on an algorithm to detect things on images
@drhafez0
7 ай бұрын
Can help me decide, is MacBook air m1 good for starting on the ai and ML filed , or better to get a Nvidia GPU laptop ?
@atharvmukane4768
4 ай бұрын
Please reply to this.I'm buying m2 air now
amazing, I tried to get all this installed for the last few days and failed, with the video it was so easy. Thank you so much!
Thanks Daniel! After trying multiple other tutorials I was going to give up, but I got TensorFlow working with this tutorial!
WOW!! Speechless literally I was just about to give up and start doing Machine Learning on my old pc if it were not for this I would have been coding on a toaster. Thank you Daniel very though rough video and very helpful.
There are dozens of videos that I have not been able to utilize, this one is so useful. Thank you!
@mrdbourke
Жыл бұрын
Thank you! Glad you enjoyed!
You are a life saver man! Had been stuck trying to get tensor flow working on my m1(I'm new to Python and ML) and after trying out countless ways I finally found your video. Thanks a ton!
@MadhanSidharth
Жыл бұрын
Can we run code on gpu
Thank you very much. I was trying to install tensorflow for two days, i couldn't find any way, your video solved my problem. Thank you very very much.
Hey man. You saved my life. I am very grateful for your help. I ended up using my old windows laptop for my project because tensorflow was not running on my m1.
Best tutorial ever! Now I can finally use my mac to do the deep learning locally. Thank you so much!
and now my M2Pro chip comes to life in tensorFlow. Thanks a million, man!!
thanks a lot for this video, i tried many diff videos on yt and yet none of them worked but i successfully installed tf using ur video, really glad i fond this video
Awesome Video Daniel !! Such a crisp explanation for the process
Literally the only guide on the whole internet that actually works
Daniel - sincere thanks for sharing your hard won knowledge and skills. You are an open and supportive person. Cheers ! ... Well Done !!
Dear Sir,I am an international student at UOM,and I was doing preview for the 2nd year study,your video helped me a lot on tensorflow!!thank you!
@mrdbourke
2 жыл бұрын
You’re welcome Chen!
Thanks this worked better than the other solutions I've seen on KZread
As always great content sir... kudos !!! My new machine arrives this week, very excited to reproduce this tutorial on that.
@mrdbourke
2 жыл бұрын
Thank you Vlademir! Enjoy your new machine
Thank you so much daniel....i have been trying from the past 4 months to install tensorflow on mac....this really helped me a lot :-))
@mrdbourke
2 жыл бұрын
You’re welcome Sai!
Omg thanks ive struggled for so long to get this running 🏃 But you came to save my in the Mac terminal lost souls
Thanks! These instructions worked on M3 Pro as well! You saved my day!
@mrdbourke
7 ай бұрын
Glad to hear it worked!
I recently purchased macbook air. I was facing difficulty in installing ML libraries. This is very helpful. Thanks :)
@mrdbourke
2 жыл бұрын
Hey Pankaj! Glad to hear :) did you get it all setup?
Best video! The only video all things worked On M1 Mac as per 2022
bought the mac pro 14 the same day you release this video. Thanks so much for this video
@mrdbourke
2 жыл бұрын
You’re welcome Rich! Enjoy your new computer
BRO YOU JUST SAVED ME DAYS OF RESEARCH. THANK YOU SO MUCH
Still waiting on my M1 Max to show up after ordering the week after the release. Thanks for these videos. Would love to see more about how you setup you dev environment in general.
@mrdbourke
2 жыл бұрын
Woah! They must be popular if you still don’t have it… as for my dev setup I usually make a Conda environment (similar to the video) for each different project. The environment lives inside the project folder so everything for a project is in one place.
@matija-ziberna
2 жыл бұрын
Into my third week:)
@0x007A
2 жыл бұрын
@@mrdbourke what are your thoughts on using containers to isolate each development tool from the host computer? I have been using containerized Python, pip, pipenv, pylint, and Jupyter to (1) ensure the same development environment is easily reproducible and (2) avoid "polluting" the host computer with globally-installed development tools and libraries.
Really helpful !! Will stay tuned to more of your videos.
@mrdbourke
2 жыл бұрын
Thank you Amit!
gone through many tutorials but found this one the best....and works,, so, I am subscribing you...
@mrdbourke
7 ай бұрын
Glad to hear it works!
You saved my £1500 man i was about to break my mac pro and wanted to get windows You are such a beauty thank you very much everything worked on my mac
@mrdbourke
2 жыл бұрын
Enjoy!
Thanks a million, after spending several hours trying to solve it, I finally managed through you. Cheers :)
@mrdbourke
2 жыл бұрын
You’re welcome Shady! Glad you got it working!
Thank you so much Daniel. Very happy and grateful to you 😊👌🏼👍🏼
Only thing that worked for me after multiple hours!! Thank you so much!!!
@mrdbourke
8 ай бұрын
Glad it worked Olivia! Happy machine learning!
Great tutorial! I have run into an error when using conda install. Towards the end, preparing transaction is done, verifying transaction is done, then executing transaction fails because of bad interpreter: No such file or directory. Before it says the last line, I can see it cut off my directory (a folder inside my documents but before tenserflow-test folder) because it has a space in it. Can conda install not get past folders with spaces in them?
Thanks a million Daniel. Though, I have one question to ask, Is there any reason that you downloaded Miniforge at the Home directory instead of the root directory? when I've compared the anaconda location with my other intel devices (where I used brew install) they just downloaded Under the root/opt directory and there seems to be a little difference in making new environments with the following common command "conda create --name env_name python==version"
Thank you for your detail explanations. But I have a problem to use jupyter notebook. When I type "jupyter notebook" like you (11:15), occured. Someone says its reason is UTF-8 encoding, but i can't solve the problem though i changed the setting. If you know anything about this, could you tell me? Again, thanks a lot for the video!
Well, i hVe learned alot from you. I have took your lectures from udemy.. i am really thankful for that. Stay blessed and keep it up.
@mrdbourke
2 жыл бұрын
Thank you Irfan! Keep learning legend
The legend back again. Thank you Daniel!!
@mrdbourke
2 жыл бұрын
You’re welcome Ali! Plenty more videos to come :)
hi, thanks a lot for a great video, however i am getting some numpy version incompability 1.19.5, any idea?
Hi Daniel, Thank you for this video. I have one question How to install other package when needed. Can you please tell me.
Great and clear instructions !! Thank you a lot. :-))
Very useful tutorial. Do you have any idea of how I can install mediapipe in the ./env?
hey Daniel, I m having problem in installing tensorflow-text please can u make a video on it
Thank you for this. I have to try this with my M1 MacMini. Bought it about 6 months ago and I was disappointed how hard it was to make it work with ML/DL libraries. M1 has been mainly collecting dust. Time to do upgrade to OSX and try your step by step video. Maybe there is still some problems, but month by month we get new libraries which support ARM better. (Now I do not remember which libraries were hard to get going on 6 months ago, maybe it was gym and ml-agents, mainly reinforcement stuff)
@mrdbourke
2 жыл бұрын
Hey Harri, I was the same when the M1 first came out. But now I find it works basically the same as all of the other machines I do machine learning on. Especially with TensorFlow-macos and TensorFlow-metal, installing these were a breeze to get TensorFlow running on the GPU
@nathanlewis42
2 жыл бұрын
@@mrdbourke I just installed on a M1 Mac mini and it doesn't work. The import tensorflow as tf line in the notebook gives the error: dlopen ........ Symbol not found: _OBJC_CLASS_$_MPSGraphCompilationDescriptor
Hey , Can you make one more video regarding the installation with the updated instructions. I think there have been few changes in the last year.
Im getting this error: could not find a version that satisfies the requiremnt tensorflow-macos (from versions:none)
I forgot also the question; to install Miniforge I have to conda deactivate the (base) env, right?
I tried to install tensorflow in the folder you named in GIT, it didn't work saying that tensorflow module cannot be found. Then I installed it in main folder, it worked. How is that possible?
Hi, I still have some problems when running codes of RCNN mask model. I have already downloaded pycocotools modules, and I can see it is under miniconda. Still, it keep saying there is no module called pycocotools after I successfully downloaded, do you know why and how to fix this?
its working pretty good but i have question i have exit the terminal after all this and then when i open the terminal and type jupyter notebook it said invalid command could you please help me with this ?
Hi Daniel, i followed all the steps, but when i import tensorflow as tf, it still wrote Error: Initialization Failed. How do I solve for this?
Is there a way to use Machine Learning with Tensorflow on the GPU inside of VSCode?
I am getting following error in MBA m1 ERROR: Could not find a version that satisfies the requirement tensorflow-macos (from versions: none) ERROR: No matching distribution found for tensorflow-macos
I did everything and everything goes well. However, while I start training, the kernel becomes dead. Any solution that?
Does this work with virtualenv + pip without having to install conda?
Failed to build h5py. Can you please solve this issue I really want to use Tensorflow
I tried tried your way 4 to 5 times but even after installing it shows module not found on m1 macbook air
i tried to install another library like seaborn opencv tranformers gymnasium its not worked
how do i set my enviroment to run tensorflow on m1 gpu?
Hi Sir, could you please let us know how to install tf-models-official. thanks.
Thanks a lot! It worked on my Mac.
In this way, for every project should i have to create a new directory and set environment? Can you please show how to set up a an universal environment and play around different projects
I have an M3 Max and the metal install fails. Is there an updated process? I get the following python -m pip install tensorflow-metal ERROR: Could not find a version that satisfies the requirement tensorflow-metal (from versions: none) ERROR: No matching distribution found for tensorflow-metal
It is an incredible video as it is the first time to successfully download tensorflow libraries on my mac. Unfortunately, the step when I am supposed to successfully run the code on Jupyter notebook did not work (1st create new python files leads to: "500: Internal Server")(2nd if the 1st step worked using: "pip instal --upgarde nbconvert", then when executing the code libraries like numpy are not found). These libraries such as numpy, pandas, and matplotlib could be imported successfully if I opened the python files using visual studio code, except for tensorflow. I'm still looking for an explanation and a solution for such problem.
Can someone pls help with installing SPYDER, JUPYTER LAB, GLUEVIZ, QT CONOLE AND R STUDIO through terminal
Everything worked but when i try to create a new python file in jupyter as shown, it says "500 internal server error" how to fix this?
the jupyter is not importing pandas or numpy or anything else. shows IMPORT ERROR. please help
Could you show us how to clean your HOME directory? After doing all this plus some vim config and stuff, the HOME directory gets messy as fuu
THANKS! GREAT VIDEO
Basically wonderful tutorial Thanks a lot!
I couldn't open jupyter notebook after installing it. It says "zsh: command not found: jupyter"
Hi Daniel, thank you for the Video, after following the instructions while connecting the Jupiter notebook I am getting error "RuntimeError Traceback (most recent call last) RuntimeError: module compiled against API version 0xf but this version of numpy is 0xe --------------------------------------------------------------------------- ImportError Traceback (most recent call last) ImportError: numpy.core.multiarray failed to import The above exception was the direct cause of the following exception: SystemError Traceback (most recent call last) SystemError: returned a result with an error set The above exception was the direct cause of the following exception: " Request you please advise
@BlinkDrive555
Жыл бұрын
same to me.
@Daniel Bourke. Excellent tutorial. It worked perfectly. I'm using R for some CNN. Can you make a video on the TensorFlow, Keras, and R integration?
Hi, i followed exactly how you did, i got this message: 500: Internal Server Error, what to do? 😢
chmod: Unable to change file mode on /Users/aurnob/Downloads/Miniforge3-MacOSX-arm64.sh: Operation not permitted showing this..help me out!
life saver. Thank you
Seriously appreciate this video! Thank you
@mrdbourke
Жыл бұрын
You’re welcome Michael! Happy machine learning :)
i m using macbook air m2 and when i ran this code it was running very well but at last it showed intialization error
Thanks so much Dan, you are the best. Life saver than a CIU
@mrdbourke
2 жыл бұрын
You’re welcome Russell!
excellent job - helping a lot 🙂
What is the total size of the whole installation on SSD ?
how do i get all this knowlegde that you have? where can i learn from?
Thank you! I followed the instructions, yet when I'm trying to train the model, I get: 2021-12-22 01:31:43.125470: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz Epoch 1/100 Any ideas why that is?
thanks a lot. it helped me to get my macbook successfully work
@mrdbourke
2 жыл бұрын
Stoked to hear Mohamed!
I keep getting "ERROR: Could not find a version that satisfies the requirement tensorflow-metal (from versions: none" :( I am on python 3.8.15
I download Miniforge 3 but in terminal it states there is no such file or directory
how was your experience after this? Was Machine learning projects going ok in MacOS?
how to get jupyter notebook for r language.. please tel
Why can't we simply use visual studio code? And Google colab TPU ?
i am getting this "error: externally-managed-environment" its really frustrating me.
Thank you for this video and your clear explanations I would like to know if there is way to install the package "albumentations" on an M1 MacBook pro, I tried using conda and pip but it is not working
@mrdbourke
2 жыл бұрын
You’re welcome Jean! Glad you enjoyed As for the albumentations package I’m not sure I’ve personally never used it - you may want to check their GitHub issues page?
Hi Daniel, Please have a look at my previous comment regarding the error I am getting. Not able to set it up on my m1 mac.
Thanks Daniel, this was very helpful. Can you also make a similar tutorial on setting up PyTorch on M1 Macs? That would be super helpful.
@Anonymous-vh9tc
2 жыл бұрын
PyTorch GPU doesn’t work and will never work on M1, cpu version can be installed follow their getting started guide
@mrdbourke
2 жыл бұрын
Let me look into the best setup for PyTorch on M1!
@AravindG11
2 жыл бұрын
@@mrdbourke Thanks man, I will be waiting for the PyTorch setup tutorial.
@trefoilz7355
2 жыл бұрын
@@mrdbourke waiting for PyTorch and Transformers as well! I have troubles with those two as well.
@aimanyounis8387
2 жыл бұрын
@@trefoilz7355 Man I hope there is! , to avoid the disconnection on google colab.
Worked for me, i even run a computer vision code for segmenting roads in video files. Just had to ' conda install opencv'
is rosetta required for any components?
Such a helpful video. Can't thank you enough.
@mrdbourke
9 ай бұрын
Glad you enjoyed legend!
im using the new Mac m1 air but when I try to run conda install -c apple tensorflow-deps it throws an error saying PackageNotFoundError any help on this one?
@mrdbourke
2 жыл бұрын
Are you using Python 3.8?
Thank you so much for the video. I love it
Can we use arduino raspberry pi and others too
ModuleNotFoundError: No module named 'tensorflow' can you please reply. while i am running the code import numpy as np import pandas as pd import sklearn import tensorflow as tf import matplotlib.pyplot as plt # Check for TensorFlow GPU access print(f"TensorFlow has access to the following devices: {tf.config.list_physical_devices()}") # See TensorFlow version print(f"TensorFlow version: {tf.__version__}")
Can you maybe help me with getting this set up in vs code? I just can’t get it to work if I open the environment in vs code Jupiter tells me failed to start the kernel I tried to Google it and changed the kernel.json argv path but nothing seems to work I just wanna use Copilot to write ml :(
@mrdbourke
2 жыл бұрын
VSCode notebooks should work with this, as long as you select the right kernel, the kernel will be at the same path you created your environment