Setting Up CUDA, CUDNN, Keras, and TensorFlow on Windows 11 for GPU Deep Learning

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi this is jeffy okay let's install tensorflow cara's with full gpu support on windows 11. now we're going to install this low level using no anaconda shortcuts we're going to use anaconda miniconda but we're not going to use the pre-built version that they have it's often several versions behind of tensorflow and sometimes causes causes me issues this is how i install it on my own computer we're gonna use windows like i said and we're going to just take you through each of the steps i have the steps lined out in this video and then i also have a markdown file that gives you all the copy and paste goodness to go along with it i'm trying to make this video age well so don't necessarily just copy everything from the video copy it from the markdown let's get started so to perform this install i'm going to use really two installation guides now this may change as of the point that you're doing this they upgrade versions pretty frequently in both cuda and kudi and space but we'll we'll talk about what might change as we go through it and there's several different ways that you can go about this so i want you to follow this not exactly keystroke keystroke keystroke but learning really what's going on here and what we're going to actually do now we are going to install cuda and coo dnn and all of these separately there is a much easier way that you can go about this where you have anaconda actually manage this for you that's good and it's bad the problem is you don't always have the latest of everything anaconda tends to stay a bit far behind so this is how you install the latest and greatest of everything and keep it up to date because now you know how these individual components work so i'm going to be following the tensorflow installation guide and that will get very quickly into the cuda installation drive also for windows but before we do any of that i am going to install the latest nvidia gpu driver for my particular card and you have to put in the type of a card that you actually have for me i have a ampere they treat it essentially as a quadro it's an rtx series and i do have the a6000 so it's a pretty high end card and we want windows 11 because i am running windows 11. download type we'll do the production that tends to be the safest and we'll go ahead and search for that and here it is so we'll go ahead and download it and it's now downloading the latest driver for this we'll go ahead and fast forward through this because this takes a moment okay it's downloaded let's go ahead and run it and by the way you notice at the bottom there's the 472.84 that is the actual driver that we're installing for the video driver you really just want the latest some of the others you will have some constraints based on tensorflow and other things so specify you where you want it doesn't matter i accept the default on that it's installing now i'm literally changing my low-level video driver and screencasting at the same time what could possibly go wrong we'll see okay let's agree and continue express is good okay it's installing the graphics driver this might knock out my recording if it hasn't already i do like to reboot the computer after the graphics driver has changed so i'll be restarting my recording anyway and there goes my screen all dark okay and we're back and it tells me status installed so this is good i'm going to stop my recording and reboot okay so the next thing that we need to install according to the installation guide is visual studio and we need to install visual studio community i haven't done 2022 yet what could possibly go wrong so let's go ahead and install visual studio community 2022. if you paid for one of those highly expensive versions you can certainly install those as well i believe before you get started you need to set up a few things okay so pre-install all right microsoft gives you the whole list of things that they would like you to install unfortunately it doesn't match at all with what you need for cuda so individual components dot net i don't want anything does anybody use net anymore cloud code tools c plus i remember when c plus was all i used visual studio for you probably do not need all of the c plus stuff but there it is i'll put ms build in there i don't think we need this old compatibility stuff and i'll install my own python thank you very much microsoft yeah i think that's mainly what you need so i'm going to go ahead and click and amazingly that still takes a whopping 14 gigabytes god love microsoft so let's go ahead and install this uh that kind of scares me no no workloads i like doing my own stuff so we're installing i'm going to go ahead and fast forward through this hopefully i got that install right if not i'll edit and fix it i feel like for my computer this is more of a marriage than an install uh so this is gonna take a while so let's fast forward and by the way the reason that we need the c plus installer is not even so much the c plus plus installer but the c installer cuda's all based on c99 and you need a c compiler to compile those cuda kernels and windows lacks by default a decent c compiler like in linux or in mac it's you just go to the command prompt in gcc so this is why you need to install visual studio so with visual c plus plus it gives you not a decent c plus plus compiler but at least a c plus plus compiler and it works well for when it's intended and it looks like it's installing.net anyway it just can't help itself all right visual studio is successfully installed okay this is an often overlooked step you need to run vc vars make sure you go to this pc c program files assuming that's where you have your program files go into visual studio go to the version 2022 community vc auxiliary build and then and then bc var 64. so let me copy that path and i'm going to open a command prompt i could just double click it and run it from there but i want to see if there's any errors so vc vars 64. run that good success so now you'll be able to find the c compiler when you run cuda so now we're going to install cuda specifically the cuda tool kit we're going to use version 11.5 of cuda you definitely want to use cuda 11 cuda 11 2 we should be able to use the latest you certainly wouldn't want to use anything before that and if you're using an ampere gpu you don't want 10 it'll run very very slow so we're going to install linux i can only dream windows and then we'll do a lot we'll do version 11 of windows and let's do exe local let's get everything 2.4 gigabytes we'll fast forward to this download okay cuda is downloaded so let's go ahead and run it yes okay we'll let it extract to that location okay i will agree and continue we will do express i understand we'll fast forward through this part okay now it's in the actual installation process which we will fast forward as well okay it's interacting with the graphics driver so we'll see what this does to my recording so you'll see some screen flickering as this part goes through kind of unavoidable i'm not going to look at the samples all right now you have cuda installed the next step is coup dnn now if you want to download coo dnn you do have to have an nvidia account it's completely free but you do have to log in unfortunately to get this so i'm going to agree to the terms and we are going to download coo dnn for cuda 11.5 make sure that matches the kuda that you just installed and you could get archived versions if you needed to go old school local installers for windows blah blah blah blah let's see so here is windows and it's a zip file so we're going to download this this does not have a fancy install program like some of the other ones do so what i'm going to do is go back to the tensorflow install page because i'm going to need to unzip this into a directory i'm going to go ahead and copy these and i'm going to open up a really advanced text editor you can use something less full featured if you want paste this into here if we go back to here it is still downloading we'll fast forward through those last two minutes so here you can see when when i open that file that i just downloaded kudn it's basically just a folder so i'm going to create a tools and then in there i am going to then put in this really hairy named folder let that go ahead and decompress and now we need to get these paths into our environmental variables you could run these actual commands that they give you there that's not the windows way to do it the windows way is more using the gui i bet there's scripted ways you can do this as well but you go to environmental variables boy this looks so old school even on even on win 11. i remember this back in windows 95 i think so let's go ahead and you can see some of these environmental variables have been put in already from cuda but we need to put certain things in the path so if we go down to the path and i am going to do this at a system level you could really almost do this and this is where windows i mean it used to be you could copy this whole thing in one stroke they just do not like automation in windows so let's go ahead and deal with these one by one then since that's how you do it so we can see some of these are already in here programming files toolkit 11.5 bin so that first one is already there so let's use that as a starting point and get the include one into here so let's go ahead and open this main part just so that we can see that we can see it this is me making sure that all these paths are correct so there you go there's your cup ti and then the other one that you're going to so so now we have cup ti and then you need the include which has all your header files if you've ever done c c plus plus all right so now we have all of those and then the one that we need is this bottom one which is where cuda dnn i mean comes from which is this this and this put that in and then why not i'm gonna put the include in anyway it's not calling for that but i've certainly had to put that in in the past so these four all need to be added in older versions of windows you could just add them put them all in one line and paste them in but now i guess we have to do it like this that one in that one in that one in and that one in all right now our environmental variables are set we should be good now as far as low-level cuda is concerned so next step we're going to continue really now following my installation guide we're going to install miniconda or anaconda it's your choice anaconda has everything in the world it's huge not huge by microsoft standards but still huge minneconda has lean just what you need i like minnaconda so i'm going to get that but if you want to use anaconda and install everything in the kitchen sink then you can certainly install it at this at this step so we're on windows 64-bit i'm gonna go ahead and download that it's downloading the latest which has python39 which is what we'll use we'll go ahead and run this we'll click next agree ah just me is fine i usually try to accept the defaults on these user jeff h mitaconda so be aware that's where it's going to be at that's going to be an important directory later on this one you can choose i like to live dangerously if you've got old legacy software out there that's using older versions of python that could break some stuff if you don't do this then you've got to always run the anaconda prompt to launch things instead of your your command prompt in windows this i just i just sent them both so you don't have to install that first click and we'll do install and now we're installing miniconda if you're doing anaconda you are still waiting for the half hour download or so it might not be that bad depending on your internet connection so we've downloaded it uh yeah i don't need no tutorials nor do i want to know how to get started and finish you can install those if you want it won't hurt anything so now we have miniconda installed or anaconda you should now have something called an anna kind of prompt and if you launch your anaconda prompt you can just do python i splash version you really should be seeing whatever you just downloaded since i clicked that dangerous check box i can now go to powershell and i should be able to type python my smiles version why does it make version hard to read and you should get the same thing so that is that is how that works if you did not click the dangerous checkbox this probably is still defaulting to whatever your system python was so the first thing we're going to do is install jupyter and we're going to install jupiter in our root environment our base environment see here where it says base but first we installed jupiter and we're installing into the base environment we're going to create another environment i don't like using the base environment for much you can install this all into the base environment but the problem with that is if you install something new i like to use an experimental area something like that but let's just go ahead and do this this takes a moment so i'm going to fast forward through this all right now we have jupiter notebooks you can also put jupiter lab that that is really kind of becoming the preferred environment i'll probably flip my class over to jupiter lab at some point but this is how you just install base base jupiter i do keep jupiter as the main environment for my class because it very closely mirrors collab which a lot of the students use so now if you just want to verify that it's running just do jupiter notebook you'll see your notebook launch and wonderful so let's go ahead break out of that because we next thing we want to do is create our own custom environment and to do that we're going to use this command so now we're creating our tensorflow environment now on windows it is extremely important that you do this activate tensorflow on other operating systems you can just launch jupiter and swap around environments as you like windows for some reason they just can't get that to work anaconda so you have to do conda activate tensorflow and now see we're in the tensorflow environment so now we're going to run this command if all this does is just hooks my newly created tensorflow environment into jupyter notebook so that it can find it as a kernel make sure you're in the tensorflow environment oh and if you do get this no module named ip kernel i'm i'm doing things in the wrong order i will add this command to my little step-by-step guide but if you run that first i mean just just run this it's going to add ip kernel yes that is good now we can run the python m ip kernel install blah blah blah and now it's it's in there so what that gave you is if you go into jupiter notebook and you decide to create a new notebook there's that tensorflow one that we just added so that that's basically doing that for you okay we're gonna break out of that again i'm just doing ctrl c now we need to install tensorflow for this i'm going to do pip install tensorflow i'm mixing pip and conda but pip is going to get me the latest and greatest tensorflow you could do double equal and tie this to a version you might need to do this but i'm going to do just latest and latest and greatest so i will press enter it's going to do a bunch of stuff you can see it's downloading tensorflow 2.7 which briefly scared me because i thought of python 27 but it's pulling that down this does take and this this will support gpu since we have all of this other stuff installed at least that's the goal all right now we have that before we try anything in jupiter let's just go ahead and try this from python so i'm just going to do python and again make sure you're in tensorflow and we'll do import tensorflow as tf i'll also have this for copy and paste in my guide and then do print tf dot underbar underbar version underbar underbar 2.7 beautiful now let's see if the gpu works this is where you cross your fingers all right we're going to paste that command in this will let us know if there is a gpu available or not true this is where kind of the heavenly music plays and you're happy if you're like a lot of people judging from the comments this is where you get a a false by the way one video i've thought of putting together is installing tensorflow except everything goes wrong where i literally reproduce each of the each of the bad things that can happen what is most likely happening right here if you're seeing false is you're seeing some lines pop up and it's telling you can't find dll this that or the next and that's because you have one of those paths messed up so if if that's going wrong if you're if you're in dll hell just go back to those environmental variables edit environmental variables go to the old school windows 95 one go to your path there it is and all of these paths that you added just go to these guys one by one by one copy them go to a go to a command prompt and just one by one dir and paste them in make sure those exist that is the best way to interrogate those and if they have spaces in them do dir with quotes around them look for that kind of stuff invariably one of those will fail if you're getting dll not found now if you want to see this work in jupiter let's quit out of python and do jupiter notebook we'll just create a new one three nine tensorflow import tensor flow as tf print tf.version and then let's do that let's do that len thingy that i like to use to test the gpu there we go let's run this mess and it should say the version number and true so the gpu is now functional inside of jupiter thank you for watching this video now you've got this gpu what are you going to do with it watch the rest of the videos on my channel subscribe get the latest and you'll find out because i cover all the latest things on machine learning artificial intelligence and deep learning thank you for watching
Info
Channel: Jeff Heaton
Views: 97,382
Rating: undefined out of 5
Keywords:
Id: OEFKlRSd8Ic
Channel Id: undefined
Length: 22min 19sec (1339 seconds)
Published: Wed Jan 05 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.