Intro to Deep Learning -- L06.5 Cloud Computing [Stat453, SS20]
Key Takeaways
This video covers the basics of cloud computing using Google Colab for deep learning tasks, including setting up a Google Colab account, accessing GPU, and collaborating with others. It also demonstrates how to use Google Colab for data preparation, file management, and image processing.
Full Transcript
all right hi everyone so it's probably the third time recording this yeah it's um technical difficulties but all good things come in threes so I hope you are doing well you are staying inside let's pray the most important thing right now to stay healthy and stay safe yeah but also it's spring break so maybe do something fun we'll watch some Netflix and stuff like that but don't forget this homework three and you know a class project so for that also for me to just practice recording lectures before it gets serious next week I wanted to just give you a very brief lecture on how to run Jupiter networks on a cloud GPU for I saw in a free cloud GPU so there are many many ways you can run your code for homeworks it's usually sufficient just to use your laptop for the project depends on what you're planning to do we have some GPUs on the campus but they're a little bit tricky to use so today I just want to show you maybe the easiest way for using a GPU and that is using Google collip so that is some service by Google that offers you one free GPU at a time so what I'm going to do now if everything works as it should I will swap my screen and then I will go through some slides show you or summarize the individual steps that you need to get going and then I will show it to you in the live session in the moment my own web browser how to how I would do this so let's get started here let's get started then so in this lecture like I mentioned I will show you how to use Google collaboratory so the slides that I'm going to show you first I just uploaded them to github so this is our usual class github repository where upload all the lecture material um since this is like more like a computing related lecture I put it on six so it's like a little lecture I called it six point five cloud computing resources so the slides I just uploaded them here if you want to look at them later like usual so to start with the slides here let me zoom in here and we go okay so Google clap or collaboratory this is like a service for running Jupiter notebooks on the cloud using a free GPU so it is called Google collaboratory but no one really says Google collaboratory because it's like a especially for me tongue twister it's just usually people to refer to it as just Google call app so Google call app if you say Google call up people will know exactly what you mean so what what is Google collapse so this is just a service offered by Google that lets you run regular Jupiter notebooks in the cloud so this will be the original Jupiter night a notebook file format like the I P Y in B files that you're already used for everything for code examples homeworks and so forth because it's kind of easy let's as law allows us to include figures and also notes and latex equations so Google has its own little flavor of this so it looks a little bit different from what you've already seen in Jupiter lab or Jupiter notebook so it and so the visuals they look a little bit different so as it looks maybe a little bit fancier and so forth but it's really the same thing has some some different features but the files are the same so if you have a Jupiter notebook file on your desktop you can upload it there and run it there and also you can download the notebook from google call app and run it on your local Jupiter notebook app so how this works is basically for each notebook that you use in Google colep they will spin up computing instance Linux based computing instance your own little computing instances only you are working on at that moment what that means though is that you will be very limited in resources because I mean Google has millions of users and if they would have a big fancy computer of every user that wouldn't be feasible so these are very small virtual instances on a certain computer it's still nice though because it allows us to easily use that service and also have this free GPU the only downside is of course that it's not unlimited so usually what happens is after 12 hours max it will timeout it does so they didn't want to delete your notebook so the notebook will still be there after the trough hours however your computation will stop you have to restart it then so this is important to keep in mind if you are running a bigger experiment that means you have to design your experience in a way that you don't lose any anything after the 12 hour threshold so maybe you want to make checkpoints of your models when you train them maybe a checkpoint every hour or so that you can then reload so if you for example restart a notebook you can reload from a checkpoint and continue the computation if you want to run something that is longer than 12 hours you but it's still a useful resource especially for quick testing and experimenting it allows you also to collaborate easily I think this is also why it's called Google collab because they have some features similar to Google Docs that allow you to take notes with other colleagues when you are working on that and add comments for example yeah so the big question now is how can I use Google cup how can I get started so it's basically just you need a Google account which I think you already have if you don't have your private Google account you can just use your whisk dot edu email address because UW Medicine has some special version of Google cloud so that if you use your new address you can login with this with this one so yeah then you just head to this website and that's all you need okay there's one more thing that you need you have to open your notebook in Google call app so there multiple options you can just open an existing notebook from Google Drive now you can just CIA I'm not actually using that that often so that is actually 2018-2019 anyway so it's still useful though so I have to also to Google account since I think it's my other one in any case um there are three ways you can open the note so one is directly from your Google Drive one is by putting in a link directly from github and one is uploading it from your computer I mean you will probably use a mix of these so if you worked on some project locally you want to run it on a GPU now on google collab you probably just use this upload button then also for example when you work on something you have your notebooks on google call app and in the meantime maybe if you want to reopen it you will probably go to this tab and then select an existing notebook that you have worked on before yeah this is basically how you open it and again I will want to mention I will walk through this after we went through the lecture slides here step-by-step as well so you can see a live version of that I just so that you have an overview and that nothing goes wrong I just want to show you the slides step-by-step so that they are all so that you have a record basically that you know which step comes off the other step so one the whole reason why we actually use Google call up is that for you for example if you use the laptop you probably don't have a GPU in your laptop this offers you a nice way to use a GPU and also like a set in class even if you have a laptop in a GPU a GPU in your laptop it's maybe not the most powerful GPU and also a laptop is not really meant to run computations on for long time period would I mean there are some special networked laptops that are designed for that but it's usually not the case so you want to also be a little bit careful with your laptop you don't want to overheat it so you don't want to run very extreme long computations on it so even though you may have a laptop that has a GPU you probably don't want to run a deep learning code for on it for like 10 hours and make it super hot and then risk that it breaks and things like that so the whole reason why we use that like I said is that it gives us access to a free GPU so in order to use this free GPU that just two little tweaks or one little tweak required to the notebook you click on here on runtime then you click on change run time and by default the notebook runs on a cpu so what you then do is you just select GPU here and then you're good good to go so that's all you need to select the GPU and then the notebook will run on the GPU what's nice is also that there's a torch installed now I mean Google it's they have their own framework a tensorflow like you know but so in the beginning you had to install torch or PI torch in order to use it there but now it also comes pre-installed so actually you can just import PI torch as usual and it's good to go it's also the most one of the most recent recent versions this is actually quite nice that we don't have to install it all myself stave some time and also though you may need to use certain packages that are not installed there yet so this is also not a problem I think I've showed you that before if you want to install a package you can either use the command line or you can do it directly and the jupiter notebook similar here you can just use this exclamation mark symbol and then if you use that that symbol everything in the cell is executed like shall a UNIX shell command so by executing this I will just install this watermark package it's just an example for an arbitrary package yes so I'm just checking what I wrote here is my notes on the slide so this is just what I said basically you can use that to install additional packages ok so no I mean just to give you an hands-on example of how that works I thought maybe uploading the homework there might be intuitive or useful thing to do so if just uploading some arbitrary code but of course this is not just for your homework everything what I'm showing you applies to any notebook you have and also your class project so like I said before you can actually use this github a pair tap and then you can directly provide the github address here and then it will open the notebook or like I said you can just upload a notebook from your local directory if you already have it on your computer okay so let's assume I open this notebook from github directly the homework one thing I have to do I always recommend saving frequently so one thing that will show up if you have not safe to not forget is then it will ask you to save a copy in your Google Drive folder so you just do that and then you have a copy of your notebook on your Google Drive so that was the notebook that we just fetched from github now let's assume I ran a bunch of code in the notebook at some point I will hit a cell where I get this arrow here so that basically tells us okay there is some some issue with the file here assume I don't know that every so in the you've probably already seen the homework there were instructions for downloading files and unzipping it so assume I unzipped this file or exists still it will show me something like no such file or directory so this is a common issue in Google collip that yeah we want usually to run our code on some data set and how do we get the data set onto Google collip because of course we just uploaded a notebook but we didn't upload an data set so this is unfortunately a little bit trickier I would say the one aspect that may be a little bit annoying but it's actually easier to solve than you think so how we get our data onto Google collip so there's one button first or one option first it says on a file locate in Drive so this means find the notebook so the notebook I'm having open here in my Google Drive folder so when I do that it will show me exactly where my arm notebook is you should so this is actually so the notebook that I just showed you would be this one however what I recommend is you just create a new folder where you put all the homework code in so what I wanted to tell you is there is on your Google Drive main folder just called my drive and another's main folder by default there should be a folder called Google collab sorry collab notebooks and this collab notebooks folder usually contains all of your notebooks I mean you can put them anywhere you like but this is like the default location I just recommend using that one so it doesn't get too confusing so and in this Google collab notebooks folder I recommend making a new folder for each project so here let's assume I made the new folder for homework 3 and once we've done that so what I recommend and doing here in this case is just uploading your notebook files i will show you life oh I would do that in a few moments so assume I already uploaded the notebook files here so I have the homework 3 data preparation file the homework 3 main file and also the data files here in the more than that multiple data files let's assume I have already uploaded them I mean you can just open them conveniently using right click open with context and then Google collaboratory so that is also then how you open them just from your Google Drive so but back to the so you can see here my it's a little bit hard to see what's hidden by the menu but the data files are actually there however I still got the arrow that I showed you a few slides ago so if I go back so I still still get this error and the reason is that the notebook we open it we open it from Google from Google Drive however it is still in its own little instance so I told you when you open a Google Notebook it will spin up a computing instance and this is not yet connected to our Google Drive it sounds weird but just think of it we have data here and then when we open it it goes to some other computer I am Not sure to draw a computer notice because it's just the virtual rack let's say so a rack here so ok modern computers don't have one it was anymore you just want mean computing workstations you just look in my SSH anyways so let's it opens here on a virtual space on this computing wreck but then it can't really whoops sorry I went okay so but it can't really access the Google Drive by default so this is it should you would think it should be able to access everything that is still sitting on my Google Drive however it's a little bit isolated now so you can think of it basically as we launch it and then we break the connection to our Google Drive so what we have to do explicitly is we have to mount Google Drive so yes one additional step then we do we have to mount our Google Drive on this virtual instance this is I would say maybe a little bit annoying it's necessary but I have to admit it is annoying okay but it's simpler than you might think so what you have to do is so I have an example here so you impart this okay sorry so we import this drive package from was actually a sub package from the Google collab package so this is just something you have to remember doing I mean if you have these slides you can just refer to the slides you don't have to memorize this so this is Drive package and theirs might be even I actually don't know what it is could be a class but then you would usually spell it with an uppercase letter anyways so this is mount method that you can use to mount your Google Drive so again this is something you just have to remember remember this is just the main location where your Google Drive sits with relation to the virtual instance if you execute this code block so this is just something you can copy from the slides for example you don't have to memorize this if you execute this what happens it will happens is you will get this prompt that asks you to go to this website here and then it asks you to enter an authorization code so this website here there will be an authorization code that you copy and you just put it here and once you've done that for example if this is a second step so I've done this here then you should see it will take a few seconds you should see something like mounted at content drive so it will take a few seconds but then your Google Drive will be mounted and once you wanted that everything should work fine so here I one thing I have to do though is I have to replace the links the relative links I had in the homework with the absolute links on Google Drive now so this link is new this link is new this is new and this is new and so again so this is the base the base path the content drive that we just mounted and then like I showed you before where our notebook is located is this H wo3 folder within my drive and Google colep notebooks so this is actually the folder if I go back oops too much where was it here so this is actually the folder I was showing you here so this is my drive collect notebooks and then hwo three so this is just the link that I put in here so this is this part okay so this is just I mean a concept explained in slides I mean slide slides are not really ideal for explaining concepts like that there are more interactive so let me also do this life or at least trying to do that life because doing something life is never as smooth as you would think all right so let's just start by going and going to Google call it so I just type google call up in to Google or any other search engine that you might like so there should be some option google app which I could just click yeah and so there are options like I said to create a new notebook here what we want to do let's say we want to upload our notebooks so what I would do is for example I would upload an existing notebook like ipython notebook file here I P Y and B however since we have multiple files multiple homework files it may be a little bit annoying to upload each file individually so what may be easier is to just go to Google Drive alright so let me use my whisk dot edu account alright so I told you there is a folder called my Drive collab notebooks so what I'm going to do now is I will upload homework 3 so homework 3 this is all the files that are on github so I will just drag and just drag and drop them all right think so it's slow here ok this is uploading also what we will need this is described in the homework are the data files let's just assume I donated them to my computer and I will just also upload them here so these are the data files in the meantime I can already open this notebook oops it's jumping around open with Google collaboratory so that's data preparation of book so what we have here is the instruction so I assume we already know the data set I mean there are other ways you can download it directly there's a tool on the command you can type on W get and then click on the link and so forth but we just assume you have the data on your computer for now so you do the unzipping and for this one like I told you before we need to mount a Google Drive because right now the data sits here next to our notebook so here are data files but we don't have really access to it yet unless we are mount of Google Drive so again mounting the Google Drive that was these few steps here from Google Cola import drive and then drive mount content to drive is my folder so let's do this a new cell here from Google Apps and okay so it will ask me to go to a new webpage now here so and click here use yep I think all right so yeah should read this carefully of course but I think I read this already so at some point so I just trusted for now okay so copy this and enter it here no I don't want to save this so it will take a few seconds all right so it's mounted now and like I said we now need to adjust the link so right now how this code works it will look for so the code I've written here will look for you by 2gz files in the current directory so this is just the current directory however we need to provide the absolute link which is conte and stood drive and then was it on my drive I think and then notebooks um I mean I think this should be it we will see in a moment okay executing this is not correct okay let me double check what's going on here oh did I forget anything notebooks what did I write there right now that's correct okay oh why does it not work so what is wrong here come to drive come to drive okay first issue here this is a little weird call up notebooks my drive what is the arrow here maybe I need I don't think so but all right so this is apparent see that is why I don't like a live lectures I mean like I left demonstrations with tools tools that are not my own are we missing a failure no not really can't explain this can't see a typo here which is the super awkward okay my monitor is a little bit small but I don't think oh okay there we go yep that happens so I was so focused on this one let's make a new yeah yeah so I have a completely doable look at this part so what what basically happen is it will just use Z which is just the file and inside the folder instead of the whole file so we need to we need to create a complete absolute path so what we do is we just put this one here Z and then we replace path so that should work there we go okay it should have worked so we unzipped the gzip files and then we are going to load them so we executing this part again I need the main folder so I copy this part here because otherwise it will look next to the notebook but again this does not work on Google Drive for some reason so we provide the link explicitly so that works I can visualize stuff here we want to and this is it basically creating the PNG files so we may want to use so let us let us make a new variable so we don't have to retype this all the time just double-check um everything looks okay so can we all right so come on here okay yeah it's a nice thing : okay this will generate all the PNG files there are a lot so I'm not sure I have actually not run this on Google collar before so it's also my first time for the homework at least so let's see shouldn't take too long so whatever was just doing is I was adjusting all the fire paths you don't have to do this locally but yeah you have to do that for good like Google collab which is a little bit annoying so maybe one one little trick something you could do is when you I have a code notebook and you assume everything is relative to this notebook to the directory you can maybe make um variable call it it's a main directory or something like that and if you work on your local notebook you can just put a dot here and then if you change to Google no collaboration or notebook excuse me so you can just add this complete a path and everywhere where you had the dot before you replace everything just with main directory and you just use either this one or this one so you don't have to change everything every time in the notebook so I'm not sure why it's taking so long let's check what it is doing here so is it not really creating anything here we're not okay it's creating the PNG files here can we see how how many no it does not okay okay some of them are being generated mm I don't know how long that will take to be honest it was pretty quick on my computer like a few seconds okay so maybe I don't have to really run this will take maybe a while so you should of course work through the rest of the homework notebook I mean this is again something that you can do on your local laptop it will take a few minutes only and you don't need a GPU for that it's just like an example and then when you go to the other notebook file this one you unfortunately have to again go through the mounting exercise which is a little bit annoying but this is the main notebook that is basically running your code so here when you want to if you want to take advantage of a GPU you would go to run time change run time type and select oops select on the GPU here again this is a very small homeworks and this homework you've probably already seen that you are just experimenting with a multi-layer perceptrons so here this network is so small and simple and the data set is so small and simple there's not really any much to gain from using a GPU over CPU you will maybe see a very small difference but it won't be substantial and it's maybe not worth using Google collip for this however I just want to show you the general option that it exists so you can use that for your project and maybe for later homeworks so after Spring Break we will talk more about different optimization algorithms and then we will get to a new architecture convolutional neural networks so yeah I'm not sure how long that will take so I don't want to so you can go back to Netflix I don't want to hold you up too long because this is not super exciting here anymore so yeah this is just a brief overview I will upload the video to YouTube and I will share it on Piazza so in Piazza we can have the discussion then so that's our normal forum where we discuss things so okay then let me stop this here
Original Description
Sebastian's books: https://sebastianraschka.com/books/
The lecture slides are available at: https://github.com/rasbt/stat453-deep-learning-ss20/blob/master/L06-pytorch/L06.5_cloud-computing__slides.pdf
Introduction to Deep Learning and Generative Models (Spring 2020). Optional lecture 6.5, explaining how to use Google Colab for Jupyter notebooks with a free GPU.
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Sebastian Raschka · Sebastian Raschka · 1 of 60
← Previous
Next →
▶
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Intro to Deep Learning -- L06.5 Cloud Computing [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- L09 Regularization [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- L10 Input and Weight Normalization Part 1/2 [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- L10 Input and Weight Normalization Part 2/2 [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- L11 Common Optimization Algorithms [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- L12 Intro to Convolutional Neural Networks (Part 1) [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- L13 Intro to Convolutional Neural Networks (Part 2) 1/2 [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- L13 Intro to Convolutional Neural Networks (Part 2) 2/2 [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- L14 Intro to Recurrent Neural Networks [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- L15 Autoencoders [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- L16 Generative Adversarial Networks [Stat453, SS20]
Sebastian Raschka
Intro to Deep Learning -- Student Presentations, Day 1 [Stat453, SS20]
Sebastian Raschka
1.2 What is Machine Learning (L01: What is Machine Learning)
Sebastian Raschka
1.3 Categories of Machine Learning (L01: What is Machine Learning)
Sebastian Raschka
1.4 Notation (L01: What is Machine Learning)
Sebastian Raschka
1.1 Course overview (L01: What is Machine Learning)
Sebastian Raschka
1.5 ML application (L01: What is Machine Learning)
Sebastian Raschka
1.6 ML motivation (L01: What is Machine Learning)
Sebastian Raschka
2.1 Introduction to NN (L02: Nearest Neighbor Methods)
Sebastian Raschka
2.2 Nearest neighbor decision boundary (L02: Nearest Neighbor Methods)
Sebastian Raschka
2.3 K-nearest neighbors (L02: Nearest Neighbor Methods)
Sebastian Raschka
2.4 Big O of K-nearest neighbors (L02: Nearest Neighbor Methods)
Sebastian Raschka
2.5 Improving k-nearest neighbors (L02: Nearest Neighbor Methods)
Sebastian Raschka
2.6 K-nearest neighbors in Python (L02: Nearest Neighbor Methods)
Sebastian Raschka
3.1 (Optional) Python overview
Sebastian Raschka
3.2 (Optional) Python setup
Sebastian Raschka
3.3 (Optional) Running Python code
Sebastian Raschka
4.1 Intro to NumPy (L04: Scientific Computing in Python)
Sebastian Raschka
4.2 NumPy Array Construction and Indexing (L04: Scientific Computing in Python)
Sebastian Raschka
4.4 NumPy Broadcasting (L04: Scientific Computing in Python)
Sebastian Raschka
4.5 NumPy Advanced Indexing -- Memory Views and Copies (L04: Scientific Computing in Python)
Sebastian Raschka
4.3 NumPy Array Math and Universal Functions (L04: Scientific Computing in Python)
Sebastian Raschka
4.7 Reshaping NumPy Arrays (L04: Scientific Computing in Python)
Sebastian Raschka
4.6 NumPy Random Number Generators (L04: Scientific Computing in Python)
Sebastian Raschka
4.8 NumPy Comparison Operators and Masks (L04: Scientific Computing in Python)
Sebastian Raschka
4.9 NumPy Linear Algebra Basics (L04: Scientific Computing in Python)
Sebastian Raschka
4.10 Matplotlib (L04: Scientific Computing in Python)
Sebastian Raschka
5.1 Reading a Dataset from a Tabular Text File (L05: Machine Learning with Scikit-Learn)
Sebastian Raschka
5.2 Basic data handling (L05: Machine Learning with Scikit-Learn)
Sebastian Raschka
5.3 Object Oriented Programming & Python Classes (L05: Machine Learning with Scikit-Learn)
Sebastian Raschka
5.4 Intro to Scikit-learn (L05: Machine Learning with Scikit-Learn)
Sebastian Raschka
5.5 Scikit-learn Transformer API (L05: Machine Learning with Scikit-Learn)
Sebastian Raschka
5.6 Scikit-learn Pipelines (L05: Machine Learning with Scikit-Learn)
Sebastian Raschka
6.1 Intro to Decision Trees (L06: Decision Trees)
Sebastian Raschka
6.2 Recursive algorithms & Big-O (L06: Decision Trees)
Sebastian Raschka
6.3 Types of decision trees (L06: Decision Trees)
Sebastian Raschka
6.5 Gini & Entropy versus misclassification error (L06: Decision Trees)
Sebastian Raschka
6.6 Improvements & dealing with overfitting (L06: Decision Trees)
Sebastian Raschka
6.7 Code Example Implementing Decision Trees in Scikit-Learn (L06: Decision Trees)
Sebastian Raschka
7.1 Intro to ensemble methods (L07: Ensemble Methods)
Sebastian Raschka
7.2 Majority Voting (L07: Ensemble Methods)
Sebastian Raschka
7.3 Bagging (L07: Ensemble Methods)
Sebastian Raschka
7.4 Boosting and AdaBoost (L07: Ensemble Methods)
Sebastian Raschka
7.5 Gradient Boosting (L07: Ensemble Methods)
Sebastian Raschka
7.6 Random Forests (L07: Ensemble Methods)
Sebastian Raschka
7.7 Stacking (L07: Ensemble Methods)
Sebastian Raschka
8.1 Intro to overfitting and underfitting (L08: Model Evaluation Part 1)
Sebastian Raschka
8.2 Intuition behind bias and variance (L08: Model Evaluation Part 1)
Sebastian Raschka
8.3 Bias-Variance Decomposition of the Squared Error (L08: Model Evaluation Part 1)
Sebastian Raschka
8.4 Bias and Variance vs Overfitting and Underfitting (L08: Model Evaluation Part 1)
Sebastian Raschka
More on: ML Maths Basics
View skill →Related Reads
📰
📰
📰
📰
I Found the Neural Network I Built in Class 9 — Here’s What Happened When I Tried to Run It Again
Medium · Deep Learning
Introduction to Deep Learning and Neural Networks: From Human Brain to Artificial Intelligence
Medium · Deep Learning
Want to get started with deep learning
Reddit r/deeplearning
Building a Deepfake Detector From Scratch — What Nobody Tells You
Medium · Deep Learning
🎓
Tutor Explanation
DeepCamp AI