Install Tensorflow/Keras in WSL2 for Windows with NVIDIA GPU

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
let's go ahead and install tensorflow onto windows with GPU support or without gcpu support we're going to talk about both so when you're looking at how to install tensorflow into Windows you're going to be on this page here on tensorflow and I've got a link to this down in the description but let's look at what our options are as of March 2023 so Windows native this used to be supported tensorflow is kind of throwing up their hands on this one and saying yeah we're giving up so no more native installs of the GPU in Windows so you can't run the GPU just straight up in Windows from the command line like you used to at least not the Windows command line if you want to use GPU support what you're going to need to do here is follow these steps and I'll let you know some of the gotchas you're going to have to put it into wsl2 which is the windows subsystem for Linux first of all wsl2 this will work if you have CPU it'll simply just not use your GPU and if you do it with the GPU and you're on into problems that's what it's going to do too it's just going to not use your GPU and that'll be frustrating but we'll talk about that also I am using Windows 11 Windows 11 makes some of this a lot easier with the native driver support I suggest using Windows 11 for this this kind of thing I no longer have computers running win10 so I can't really I'm not really going to do videos on that I'm moving on so the very first thing that you want to do is install the Nvidia driver also I focus primarily on Nvidia I don't have AMD technology AMD technology is not real common in the cloud and so it's it's just not an area that I focus upon and it's it's a more complex path it's not supported as well in the machine learning thing and I'm all about the path of least resistance now my GPU which written video was awesome to provide for this video is an Nvidia RTX 6008 a generation really any GPU that is shown here is is going to work just the 40 series is certainly going to be faster than the 30. which is faster than the 20 and so on and so forth so let's go ahead and search and we shall download it agree and download I'll fast forward to this depends on your connection speed how long this takes okay it is running I'll say yes okay it's installing I'm gonna have to stop by recording because we are modifying the video driver so the driver is now installed so we're back here on the wsl2 now what you're going to have to do before you hop into any of this is you need to install wsl2 and for this we're just going to open up a Powershell and we're going to do WSL minus minus install and you have to give it the appropriate permissions and it's Off to the Races we'll fast forward through this part it does install Ubuntu by default certainly the path of resist resistance which I'm all about okay the system needs to be rebooted so I'm going to stop my recording for that now we're going to install minaconda follow the version that they're specifically asking for here on tensorflow anything that gives me fewer headaches is a good thing so let me go ahead and I am going to launch Powershell and let's run the first the wget command that is simply going to download it so let's pop into WSL and it will download it that goes relatively quick at least it did for me now we will run the shell command that actually installs it [Music] okay I'm gonna press enter to continue yes we wish to install and we'll install it to that path fast forward through this yes we would like to initialize the shell we'll see why that is important here right now it's not really telling me my virtual environment but it should be telling me that we're in base so if I exit from WSL and then I go back into WSL you'll see that we now have base here so let's go ahead and create one of those environments so we're going to use this next command here and kind of create a python 39 environment called TF we'll press enter and we're creating a virtual environment now realize this is a virtual environment inside of a virtual environment because we're already in WSL so we'll fast forward through this and it's done so to activate this environment we do conda activate PF and now we're in that TF environment now if you're going to run the GPU run this section here Nvidia SMI we did that previously but let's just make sure it's still there and there it is now notice we're in Cuda 12. there's going to be multiple cudas installed but just one graphics driver this is your graphics driver that we installed previously and you can you only got one of those persistent if you upgrade it you upgrade it always keep your graphics driver on the latest one but Cuda depends Cuda 12 this alone would give you a problem because tensorflow doesn't currently support Cuda 12. good at 12 is very new as of the recording of this video so what we're going to do here is install Cuda 11 not system wide not even WSL wide but for this TF environment that we have here and you'll see we're we're in TF so we're going to paste that in we're going to run it and it's going to install all of these various little libraries that we need to actually make use of the GPU fast forward through this this takes a moment yes we wish to proceed this takes maybe a little bit so we'll fast forward okay now we have Cuda and the other necessary stuff installed this next part that they ask for this is making these available to everything else in your environment such as tensorflow because this specifies the path if you just run this here it's going to be good for your current run but you go reboot your computer come back later and nothing will work so so I recommend doing this and this part will set you up so that it automatically runs this command when you come back in so we're going to run these one by one put that in and then we're gonna run this little command that actually adds the path command so that it gets executed every time you boot up your WSL environment so we're going to copy this part we're going to upgrade pip let's make sure that we get the correct version of tensorflow and then what they're asking you to do here notice they're saying pip install tensorflow to 11. I don't suggest you go and install 211 unless this page is saying to do it this part this is actually what sends most people off the rails is if you're not putting these versions on you would have ended up with Cuda 12 which is not going to work with tensorflow211 or or these kind of things so the keep keep your Rubik's Cube aligned and make sure you're in tensorflow TF and we'll run it and it's downloading and installing let's fast forward through this all right awesome awesome awesome now they have the verify install don't just do the verify CPU install unless you just installed the CPU and that's fine we're going to do the GPU one but before we do that I am going to reboot the machine all right we are back so let's uh see if this works this is where stuff goes wrong if it's gonna go wrong open up Powershell and there's Powershell let's do WSL so that we're in WSL so here we are in base we're going to activate TF and there we are we're going to run this command here for the GPU paste it and press enter oh my gosh an explosion of Errors don't worry you're fine tensorflow just likes to vomit useless crap at you and this is what you should pay attention to down here you should have this physical device and your GPU GPU zero if you've got multiple gpus you'll see them here as well so this this is good you're done if you've gotten errors look at what it's complaining about up here all right you're all set up what's the next thing to do subscribe to my channel so that you get plenty of things that you can now do with your freshly installed tensorflow you might also be interested in running tensorflow with Docker I've got another video talking about that and that sometimes saves you some of the trouble of the software rotten things breaking after you've installed this
Info
Channel: Jeff Heaton
Views: 45,369
Rating: undefined out of 5
Keywords:
Id: 0S81koZpwPA
Channel Id: undefined
Length: 9min 59sec (599 seconds)
Published: Wed Mar 08 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.