How to Install PyTorch GPU for Mac M1/M2 with Conda

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
welcome to applications of deep neural networks with pytorch from washington university all right in this video we're going to look at how to install pi torch from the beginning on a mac m1 or m2 apple silicon and get it set up so that it's in a conda environment we do everything through conda and through jupiter for this course let's get it set up so here's the instructions for this this is the august 22 edition of these instructions these things tend to change i know on the tensorflow side these change frequently so keep subscribe to the channel give me a like if this if this video is useful that way you'll keep up to date with changes to to this material now i suggest installing miniconda i like using miniconda it's a python environment has lots of scientific packages available data science that sort of thing i use miniconda rather than anaconda they're both from the same company but miniconda does not install a whole plethora of additional packages for you everything and the kitchen sink miniconda is just the kitchen sink so we're going to install that first now before i even install that i'm going to show you really quickly how to just remove anaconda if it's already there so that you can get a clean install if you have a intel x86 version of miniconda or anaconda installed on your computer and you try to then use the apple silicon on top of it that's not going to work you need an arm 64 version of miniconda or anaconda available so i'm going to go ahead and just open up a prompt and i'm going to open another tab and just look at uninstall anaconda on a mac and they have a nice article here i suggest going to that you want to install this package first this is going to remove a lot of the i don't know just shrapnel that gets left in your system from installing anaconda or miniconda and it's just going to go through go through that and we're going to install it real quick this is easy and then we just run anaconda clean it runs we say yes all the little things that it finds lots of little things and it deletes it now be sure you really want to delete your environment this is a bit heavy-handed but it if you're having other trouble i suggest maybe coming back to this part and and doing the actual the actual delete so here if we look so if you look at the next commands that it gives you for the mac a bunch of removes it's just removing every place that that could possibly be installed and i'm going to go to the opt directory here and that miniconda that's that's where it was installed for me i'm going to go ahead and delete that and now you've successfully uninstalled minneconda or anaconda and i'm just going to jump back to here and do well you can see there's no python because there's no base or anything there and if i type python nothing so let's go ahead and install it now if we go to miniconda download i have a link to that at the instruction page as well you want to download this one the apple m1 if you've got an m2 same thing i like to download the package do not download the x86 or you're it's just going to tell you the package is not available and this seems to be like the most common thing that people mess up especially on the tensorflow side so we'll just fast forward through this while it downloads okay and we're done so let's go ahead and open this continue continue continue agree continue does anybody actually read those things that you agree to install okay here here we're going we'll go and fast forward through this yes we'll allow that okay and now we're done move to trash now these first two steps where i said delete python then install python you might say okay i've already got that installed i'm going to skip those two steps well here's the check to do type python and then type import platform and then platform platform and there you go uh arm 64-bit you want to see arm if you've got x86 not not gonna work okay so now that that's installed the next thing we're going to do is install jupiter we want to install jupiter to the base environment and then it will use any other environments that we create underneath it we're going to create one to start with for python but let's install jupiter this does take a while so i'm going to fast forward through this okay that is installed now this instruction is talking about how to install this with a m1 mac but you could install this cpu only if you liked on a mac just use this bottom one here cpu only nvidia cuda gpu this is not going to work on a mac but if you're following along and trying to do this in windows that's the one you would probably use but let's go ahead and copy this and you need to run this yaml file now i already have it loaded on my computer i give you a link to it in the description where i have it is in this folder where i've downloaded my entire class but just grab it from the link or get clone my entire class kind of like i did here and then you want to run this this is also going to take a while now if you are running this on an intel platform or something this is where you're you're going to go completely off the rails or if something else is wrong in your python environment you'll also probably go off the rails here if you run into serious problems i suggest looking at the yaml file and maybe seeing if you need to make any changes post your results to the comments i monitor these comments and this is how i learn about things that change and often trigger me to update these unfortunately i just really do not have time to help people one-on-one with these i get probably four or five requests for that a week and i barely have time just to keep the channel up let alone get into one-on-one debugging sessions all right there we have it so the next thing we're going to do is we're going to activate we're going to conda activate torch this is to get this environment that you just created registered as a jupiter kernel if you don't do this it won't show up on your list of available kernels so we'll run this and it's now registered we'll see it in a moment when we start up jupiter and by the way if you got any errors here google them post them to the comments section i'm always curious to see what people run into and sometimes things change usually if you're finding packages not found you've got the wrong python installed you've got the intel maybe instead of the the arm run jupiter notebook and we're going to open this exact same notebook that i had here that we were following the instructions from so we'll open that and the first thing you want to do is make sure that you've got the right kernel running so you can see that i installed that torch one and it shows up there i also ran that command that we just did to add it to two here so if you don't see that make sure you follow that that last command where we were adding the kernel we'll do that starts up the kernel and then we go down to this bottom part and we're just going to run this code just to verify that things are indeed working this does take a moment because it's got to load various libraries all right gpu is not available don't worry that's because it's not detecting a gpu it's detecting nps which is what you're using on on an apple so that's good target devices mps so this is what you'll see in a lot of the code at the top of my course material where we default to either mps gpu or cpu depending on which is available so if this worked there's one more thing you've got to do smash the like button and show me that uh that you like this video but otherwise you're set up and ready to go please subscribe to the youtube channel and you will be notified as i add other pie torch elements to this course let me know do you like that i'm adding pie torch as well as tensorflow to to my course let me know in the comments
Info
Channel: Jeff Heaton
Views: 43,593
Rating: undefined out of 5
Keywords:
Id: VEDy-c5Sk8Y
Channel Id: undefined
Length: 9min 44sec (584 seconds)
Published: Wed Aug 17 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.