Mac M1 Monterey Installing Miniforge and Anaconda/Miniconda Side-by-Side

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi this is jeff heaton in this video i'm going to show you how to install mini forge and mini conda anaconda on the same system on a mac m1 system now why would you want both of these installed well mini forge is particularly good because it supports the apple system on a chip apple metal so you can use the gpu with tensorflow on these new macintoshes you haven't been able to use a gpu on the mac for a while at least not without a lot of effort now you can you can make use of that now typically i've always used anaconda or miniconda and they're really sort of the same thing minnaconda just has everything stripped down so you have just the core and then you add on as you need anaconda is just everything in the kitchen sink so that you're not installing as as much it's just different different philosophies of how you want to go at things i'm going to install miniconda and miniforge both on this system miniconda i won't be able to use the gpu on the mac because it's just not supported but it has more packages than have been ported to miniforge and sometimes i just need anaconda to be there now that doesn't mean necessarily that every package inside of minneconda anaconda is going to work out of the box on the m1 because the m1 is just a complete re-invention of of everything there's no intel chip there it's a whole different arm instruction set so there's there's pros and cons of each but let's see how to install both of these and this is going to be a longer video than typical because i am going to show you what is happening to your mac at each step here so that you'll know how to troubleshoot there's a number of things going on and it's it's just good to know what is actually happening and how to actually troubleshoot this [Music] so if you just try to run python on this minus minus version you'll see of the ancient 2.7 version that mac ships with everything at least for now if you do where or which python very useful command it shows you that it's basically at this user bin python that is a redirected link if you ls minus ellit you'll see it's basically a link to this other more difficult to type location that mac has that installed on so let's go ahead now and install we'll install mini forge first now normally i like to use the brew package man manager which is great usually and if you're not going to have two distinct distributions of python on your computer use brew but here i'm going to install it directly because brew does a lot of magic to redirect low-level commands like condon pip and that just gets in the way if you have two entirely different distributions running side by side i mean each of these will have their own separate sets of virtual environments it's they're completely completely separated from each other so it's important to think about that because where is python at least at least usually miniforge is going to put it right under your user's directory jeff in my case right here anaconda is usually going to be off on an opt directory underneath your user account or just the root opt if you are installing a system wide homebrew will tend to put it right at the opt at the machine level underneath homebrew buried sort of deep in there so you need to be aware of where these are installed at because that way when you do a witch python you can make absolutely sure that you're where you think you are and these are the installation urls and i have this all in the description but mini forge i am going to go i'm going to go ahead and install it from this url so these are the apple instructions for this we're going to we're going to start with these steps and then we're going to use an install script that i have that does this this last part so here we are going to we don't need to well let's get to the right part actually yeah apple silicon so let's download the shell file that is going to basically install this for us we'll copy this command here that is going to upgrade the security on that file and then we'll go into downloads so that when i run this command it's modifying the file that i just downloaded we're going to do this command to actually start it and then you have to say [Music] that you you have to review the group you have to press enter to continue then you have to approve the agreement say yes i agree and then it's going to install it here remember this directory because that is where it has installed it we're going to need to know that again that's a standard location for it so i'm just going to let it go and it's extracting they tend to change around where they install things sometimes sometimes they want to at the root they like to install it under the user so be aware of that because that can that'll future proof you a bit as you're installing this i now this is important too do you wish the installer to run conda init conda init basically links it into your shell so that you see that you know that base to tell you that you're in the base environment or whatever environment don't worry we'll see in a moment i'm going to actually say no this would normally be be bad so i said no now let's see where has it modified my path if i do python mine's my inversion what are we looking like we're still on two seven does closing the shell fix that i mean always be aware of which python your path is pointing at python minus minus version we're still at two seven that's because we haven't ran that conda init and the reason i told it not to run it is i want to show you what happens if you say no or if you are seeing this normal prompt and there's no base there and if you haven't seen that before you're about you're about to so let's go ahead and initialize our shells so that every time we launch we're going to be able to see that the base prompt and be able to change our environment and have access to the correct version because if i still do python minus my version you you'll see we're still in two seven so to solve this i move into my mini forge 3 directory into bin and now i should have access to conda of course you have to prefix it with a with a dot actually let's just do the full path so that it works from wherever so there's the full path slash conda now i have access to conda i'm going to do conda and knit zsh because we are running the z shell zsh like it says at the top of my window that is what mac is currently making as the default if you have a bash up here then do then do bash but you should probably be running the z shell for mac i press enter and it tells me that i have to start a new terminal for that to take effect and i do now you see i have the base environment i am in the base environment we're good to go let's go ahead and install tensorflow on this real quick all this additional stuff that they talk about here on mac i have an install script that i like to use that will take care of all of that let me show you where it is i'll also put a link in the description but basically it's here and it is in my class website for my class that i teach on deep learning it's called tensorflow apple metal i'm going to show you this file because you may need to modify it i try to keep this file as up to date as possible but as they change things you may notice you may need to change those version numbers this is installing tensorflow 2.5.0 if you remove all these double equals it'll install the latest of everything and hopefully that'll work nine times out of ten that'll work but sometimes these move at different paces than each other so putting in these version numbers is a good safeguard against it failing so i am going to grab this entire get repository which i already did so this directory basically has my class downloaded the and i have the link in the description actually we'll continue with this right here install jupyter and create environment so from my base environment i'm going to install jupiter into my base environment so let's pop this open and paste it there we'll fast forward through this all right jupiter is installed let's do the next step i'm going to do conda deactivate being in the base environment when you do the rest of this can sometimes cause some issues so i'm deactivating that and now i'm going to run this command this command will create a new environment for you called tensorflow with all the apple metal stuff in there now it's important that we have this tensorflow apple metal yaml file it's in my class web directory on repository on github that i have a link to i'll assume that you've downloaded it i have it in this directory called user projects t81 deep learning doesn't matter that your directory is named that it just matters that you're in the same directory as it and i'm going to paste this command into there and this is going to run for a moment this is going to install all of the apple metal stuff all right we have tensorflow installed as the environment and we can kinda kinda activate it you can see now we are in the tensorflow environment and we can continue now these were some issues i think have been mostly resolved but if you got grpc io error and you got this error i give you some additional commands to resolve it this unfortunately is just the bane of your existence when you're using these state-of-the-art machine learning packages there's lots of dependencies and the owners of the dependencies do not all move at the same time or even communicate with each other all that well so you'll you'll run into issues here like this where just a change that gets pushed to one dependency breaks something else best way to figure that out is google your error and continue i'll probably pull this out at some point because i have not observed this in a while so you kind of activate it just like i told you we're going to do conda install nb conda so that we can get this hooked into jupiter yep we'll fast forward all right that is done this adds your environment to the jupiter menu so in that little drop down that you'll see in a moment if if you don't see your new tensorflow environment that you created in there that's what the problem is we'll paste it it should activate that yeah that's extremely quick just to test it i'm gonna do conda deactivate just so that we get out of the tensorflow environment and then kinda activate base this is what it would look like if you just launched a whole new one all together so i'm just getting us back to our our default sort of state and then i'm gonna do jupiter notebook and it'll launch a jupiter notebook which is a web browser and then if we go into let's just go into the first class session here if i scroll to the very very bottom you can run this code and you'll want to make sure that your environment is tensorflow which it is you can always change the kernel and you should see tensorflow right there these are some other ones that i'm working on that have nothing nothing to do with what you would see so make sure you're there and let's go ahead and run this so it's running this block of code what we really want to see out of it is gpu is available we'll fast forward through the brief initialization part gpu is available awesome awesome that's great we have mini forge installed if that's good enough for you you're done but if you also want anaconda miniconda let's go ahead and and do that okay a break out of my jupiter that was running and before i even start that here's what we're going to do and this is where we get off the beaten track so why is it that we have that base show up there what in the heck did conda init actually do to us due to your mac if you look at a file called.zshrc you'll see some some code there and look it's it's using manyforge so this has something to do with what we just set up i'm going to take my zsh file and i'm going to move it mv my current directory z dot z sh rc and i'm going to rename it to start miniforge.sh and i've renamed it now watch what this does i'm going to close that window and that one too start it up oh no where's our base python minus my version we are back to base macintosh i totally killed it but actually i did it i've i've isolated it if you do source if you do source start miniforge sh just run that now it's here now everything's happy we're in our miniforge environment so that's that's the first step for this now let's grab miniconda real quick so i'm going to the mini conda download you could just as easily do anaconda it'd be it would be all the same mac os x we want the bash i don't need no fancy pkg installer i like manual so now you've got the mini conda installer again we don't have anything installed there particularly if we go into downloads and then we do chmod plus x mini conda that file we just downloaded okay that's good and now we run it warning your operating system appears not to be 64-bit but you're trying to install a 64-bit version of this that is fine because rosetta is going to save us so we'll go ahead and say yes have to go through the usual licensing nonsense all right we are there and running notice where it's going to install it too that's fine you'll need to remember that later just press enter and it will install everything there now it's asking this question i said no to before we could say no again in fact i'll say no just so that if you do happen to not do that i'll you can deal with it so all we need to do now is run conda init so that it's going to modify our shell file so let's go back one and we're going to change into mini conda 3 bin this should give us access to conda and it does we're going to do conda that is the commander run you run that and everything should take effect if we do this now we have base again and if we do which python we can see that we're running miniforge so now what we're going to do is change back to our user directory just with a cd and if we do cat dot zsh z rc h r c you can see that it has the maniconda version in there we're gonna do exactly what we did before we're going to move the miniconda or the zsh file zshrc to start [Music] mini conda dot sh now if we look at both of those two files that we have created start miniconda start miniforge let's do these two side by side notice we don't have python in either one so if i do where which python it's just that root one but i can do source start actually don't even need that source start miniforge dot sh and now we've got our nice base environment if i do conda in the list you can see that we have base and we have tensorflow if i do because we just installed tensorflow over there and now if i go over here and do source start mini conda sh now we have our base environment conda e and b list so when we're running these side by side you can see that they both see each other and you can use conda activate to use these interchangeably the top one is miniconda the bottom two are mini forge because each has their own python and interpreter they're like complete separate instances so you can kind of activate anyone that you really want to because over here we started in anaconda so let's go ahead and do conda activate so look at these side by side it's kind of interesting because they see each other on the left side you've got mini forge and notice up here it has this first one that is unnamed that means it's a foreign installation you can activate it by the path but we're we're not going to to do that if you activate it by name you've got base and you've got tensorflow over here in many honda anaconda world it's the exact opposite the base is the only named environment because i haven't created any new named environment i could create my own tensorflow over here and i commonly do that so that i have it installed on both sides so i can use an environment on either side of the fence if i need to base since it shares the same name on each one that's why this first base is unnamed you can't have names from the other side so this is both of them up and running you now can start whichever one that you want something else that i do is for example i work primarily in miniforge when i'm on a mac so you can also copy your start mini forge to your zshr file now you have a default if you open up another terminal by default you're in miniforge as evident by that so you can make whichever one you want your default and this shows you a little bit of under the hood of what's really going on with these environments how you can sort of wield your power and take it completely back out and have a default mac or however you you want to do if you're if you just really want to run python27 for a bit all right thank you for watching this video if you're interested in more things mac m1 let me know if you want to see how to install some of the packages like i know opencv is kind of difficult some of those let me know definitely definitely like to make make use of this computer as well as my much more powerful gpu in the machine behind me thank you very much and please subscribe to the video and give me a like if this was useful
Info
Channel: Jeff Heaton
Views: 39,127
Rating: undefined out of 5
Keywords:
Id: w2qlou7n7MA
Channel Id: undefined
Length: 22min 1sec (1321 seconds)
Published: Wed Nov 17 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.