Deploy A Jupyter Notebook Server into Production using Docker & Heroku

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey youtubers what's up my name is justin i'm going to be helping you through this one now the general idea is to deploy a jupiter notebook server into production now the easiest way to do that in my opinion is using docker containers of course we use docker to make sure that we control all of the environment that's actually running jupiter and we do so in a way that's just pretty simple it's just one recipe that we use that goes forward right but one of the biggest downsides of using docker is it's ephemeral that is in jupiter we create notebooks all the time but docker's ephemeral meaning the notebooks that we create the next time we deploy a new version those notebooks are going to be gone unless we do something about it i'm going to show you how to do something about it in this one as well so make sure you subscribe to get everything i'm going to be doing a lot more stuff related to docker and jupyter because i think they're both fantastic concepts and then of course we're going to be deploying this onto heroku which is just a hosting service for docker containers but really once you know how to build the docker container you can have it hosted in a lot of places and we'll talk about that a little bit more too so let's go ahead and jump right in hey there welcome to jupiter docker in this one i want to actually show you why we use jupyter and why docker is so important for that then of course we're going to deploy it on a hosting service called heroku so just to recap that we're going to be using jupiter notebooks to make a jupiter notebook server we're going to deploy it on heroku and all of that is because of docker now docker gives us control over the environment that runs the jupyter notebook in a way that other things just don't containers are amazing so if you haven't done docker containers i highly recommend it so let's actually take a look at what it is that we're going to be building so this is the jupyter notebook server that we have now if you're familiar with jupiter this just looks like a normal jupiter notebook server locally right biggest difference here is that i can actually log out and log into this and it's on a live url so depending on when you're looking at this this might be accessible to you with the exception of the actual password right so uh you won't necessarily be able to come in here without the correct password which may or may not change over time so the key thing here is that i can actually create what's called a jupiter notebook which is just a python notebook in this case right so i can call this hello world of course if you're familiar with jupiter you're already like i know how to do all this but if you're not this is probably new to you and maybe pretty interesting so in this we can actually import some of the packages that i installed by default like python requests this is not built into python it just is a package that i installed so you can do stuff like requests.get and something like http bin.org get and then print out r.status code stuff like that right by default it's in there which is really cool so if i close and halt this maybe i want to save it first actually with control s you know i can do all the things i need to in jupiter another part of this is i can actually come in here into a running terminal or i can create a brand new one right so let's create a new terminal and now i actually have access to the terminal or bash shell right so i can call curl yeah i don't have curl so maybe i need to install it if i need it but i do have python and i can import stuff like pandas i can do all of the shell related things on here well you'd import pandas as pd as most people do you can import tensorflow stf every package that you might want to have you could totally have on our jupiter notebook now it's not going to necessarily be incredibly fast in my case i didn't actually provision that many resources to this particular notebook server but it does work and it works really well okay so there are some huge caveats about using our own jupiter notebook server the first one is the inherent nature of a docker container that is it's ephemeral it's going to go away so the next time i build the environment for my jupyter notebook server i actually need to store all of my old jupyter notebooks i'm going to show you a technique on how to do that the other part of this is heroku doesn't have gpus this is a good and bad thing so if you're trying to do machine learning you're probably going to want to have some gpus if you're not going to do machine learning this is completely fine you can actually increase the power of the cpus that you have available to actually run a more robust server on here so you could actually do a lot of development if not all of your development on this jupyter notebook server and that includes even django like you can actually build django applications using jupiter that is where i kind of say like uh maybe you shouldn't build your whole january application using jupiter but instead you should do stuff like web scraping right so web scraping is really good for jupiter as we just kind of alluded to here right so you can totally build in this long sort of story that's going on in this notebook that anybody else can use so the caveats about this are number one docker containers are ephemeral which means that all of these notebooks when we rebuild the environment are going to go away unless we save them locally first next the lack of gpus so this is where i have to tell you that there is an alternative that is provided by google they have a response to this i would love for them to but they haven't um so colab.research.google.com this has access to gpus and your python notebooks are percent persistent they update the environments all the time but the notebooks don't go away they don't just delete right they have their own kind of issues in of the notebook itself but the notebook will always stay there so those are a couple things related to what we're going to be doing of course if you have any questions please let me know uh if you've never done something like this before just keep in mind that you will want to have docker desktop and the heroku cli installed locally otherwise you're probably not going to get as much benefit out of this as you potentially could those are the blog posts i'm going to be going through so feel free to jump and follow along there and of course if you get stuck this is the github repo that we will have all of the final code it's already there to actually build this thing out so the first thing i'm going to do is actually set up my local environment inside of vs code so i am going to go ahead and add a folder to this workspace open one up and in this case i'll call this cfv jupyter and inside of here and then we'll save this workspace as cfe dash jupiter and then we'll go ahead and activate the virtual environment so i like using pipm install jupiter and we'll be using python version 3.8 okay so i'm going to let that finish installing all right so my virtual environment has installed let's go ahead and activate it pip envy shell and i'm going to just run the jupyter notebook server to make sure it's running so jupyter notebook and naturally what this will do is automatically open up a brand new server for me and there's a couple things to note number one we see the pip file and the code workspace so it already has a working environment for me and it's just based off of the directory that i'm currently in of course uh but number two it actually didn't prompt me to log in right so if i log out and go to login page it says token authentication is enabled so this is the very first thing that i actually want to change um so in order for me to do this i actually have to create my configuration that jupiter has now this may or may not already be on your local system right so your local system can have jupyter configuration by default right so you can have a lot of defaults on your local system we're actually gonna be leveraging that same concept inside of a docker container so let's change the default configuration for our jupyter notebook server so all i'm going to do here is add a password protected jupyter notebook server that we can work with locally so to do this inside of my projects directory i'm going to go ahead and add a new folder called conf for all configuration that i may need in this project i'm going to add a file for jupyter itself and it's going to be jupiter.pie now the first thing i'm going to do is just use c equals to get config and parentheses okay so this will be passed in to jupiter by default okay so next what i'm going to do is c dot notebook app that password and i want to set this equal to a password now i can't actually just put a password in here i have to use a hashed password so luckily for us ipython which is installed by default when you actually create a jupyter notebook or install jupiter itself we actually can use this command to call something else for us which is from notebook.off import psswd which is password and then psswd we actually call that so you could do it with ipython or just python itself and then print out that result ipython just doesn't need that print statement that's pretty much it okay so this reference i'll come back to you can definitely find it in many different ways let's go ahead and create our jupiter notebook server password and i'm going to go ahead and type out abc you will not see the typing here and the output is this hash here okay so literally the password is abc i did not do anything different that's all i did i'm gonna paste this in here and it needs to be a unicode string so just put a u in front of it and now we have new configuration okay so the path to this of course is conf jupiter. just like that so to actually run our project with this command it's really simple it's jupiter notebook dash dash oops notebook dash config and we'll set that equal to the path of cough and jupiter.pi okay so this should change how our jupiter notebook runs in the sense that notice that there is no token authentication here anymore um and it is serving this from this directory which is cool and so if i see the jupyter notebook that came out this is it right here right so it's real simple i just type out abc log in and it gives me that same look at the jupiter notebook okay so how did i know that this was the parameter well i've done it a number of times but that's actually not how i figured it out so go ahead and create a new terminal here and what jupiter allows us to do is actually change a lot of configuration options so you're going to want to you know just create the general config that comes in to jupyter by default so we'll go ahead and say jupyter notebook dash dash generate dash config or config and this will actually create your configuration oh yeah i should probably activate the virtual environment first okay so now that i've got that activated it's got to run it again hit enter it's asking me to overwrite this right so this is the default configuration so if you change this in the past and you change the system-wide one perhaps you don't want to overwrite this right i just did this but the reason for it is because you don't want to actually work off of the system-wide one for your local development system you want to work off of a local one like we just did so i'm going to go ahead and override that default and then open this up with command click in my case or control click if you're on a windows and here's all of those configuration options right so you can scroll down in here and find everything that you need to find everything that's related to actually changing how your jupyter notebook server works and of course in that blog post that i mentioned um well here it is right here i actually give you all the configuration that you need for your particular project um so you can actually just go ahead and copy this the only exception that you're going to want to change is the password one which is why i talked about that first so we paste this in here and i'm going to go ahead and just put my password in to what was here we can talk about some of the other configurations in just a moment i will leave the notes for generating that password in here as well which are also on that blog post too okay so the things that are happening here well there are pretty self-explanatory the notebook durs one is going to be the root directory that we want to work off of allowed origin is when we actually go on to a heroku you know app itself or we have a public ip address either one works uh you could also put the ip address here so additional configurations for the web app itself next we actually need an environment variable for the port it's going to be running on right so when we actually go into production we need this port to be set by heroku so that port right there is going to be set by heroku or our server this isn't always the case but in the heroku case it definitely is and this is actually how we're going to go ahead and change that we're going to do it by using an environment variable inside a docker which we'll get there too allow root this is not often recommended so you could say false in in your case if you'd like for me i don't see any reason why not to allow root because this is my own personal project i'm not letting anyone else use this but if you don't need to allow root then definitely say false and then also password change if you don't want to allow this to be changed at any time then feel free to say false there i actually think it'd be a good idea to say true here because you know it would probably be better to have your password not stored in a document like this even if it's hashed and then the final thing is the actual port that we want to redirect to in this case we are not using https necessarily so we add this redirect port in here as well cool so that is generally speaking what's going on with the configuration but there is certainly one more thing i need to do that we can see that is creating our root directory as in where do you want this thing to go after you actually log in so i'm going to call it mbs and of course i want this in the root of my project so right next to conf so we save that and now let's go ahead back into jupiter itself ctrl c to close it down keeping that conf going hit enter and what we should see here now is if i refresh now i've got my notebook list is empty so the root of this project is now empty it's actually in this notebooks here which is pretty cool uh so that's some of the basics of the configuration so let's go ahead and keep going so now when we actually bring this into production we have to remember that the state of jupiter notebooks or the actual notebooks themselves is going to be temporary that is if we rebuild our application and then redeploy it all of those notebooks will be gone so we need a way to actually handle that challenge so inside of jupiter i'm going to go ahead and create a new python notebook here and this one is going to be called well i'll call it pack it up and so all this is going to do is make a zip file and it's exclamation mark tar chv fz notebook dot tar gz star okay and if i run this cell and windows users unfortunately this may not work for you i have not tested it there this will work on your docker container when we get there but i'm just wanting to illustrate the point here right now back in linux users obviously it's gonna work okay so here we go what i created here was a new tar file which is a zip file that saved all of those notebooks and we can see this by creating another notebook and we'll call this unpack it okay so exclamation mark tar xv f is in file notebook we called it notebook dot tar g z okay so we run that and it unpacks pack it up so i don't actually know it's hard to tell if it actually did anything there so let's uh close and halt pack it up in fact let's delete pack it up all together and let's run the unpack it again and what do you know what we should see in here we reload it is packing up his back and we've got unsafe changed so the original thing did not save maybe i didn't save it let's try it again and notebook two dot tar gz okay so let's save this again oh i need to add a star here so this is using the current directory all files in the current directory which is now three files including the other notebook tar okay so we save this and again i'm going to go ahead and delete that one close it out up here and then unpack it again uh oh that went away too so this is a good example of how the ephemeral nature of this is going to actually happen in docker i just tried to simulate it with how we're going to do the zipping and unzipping right but actually we're going to be using the zipping and unzipping to keep these files as well and i'll show you that right now so we do exclamation mark tar dash xv f notebook2.tar gz we run that that gives me these files back right so unpack it will probably either be empty or not it's hard to say i just resaved it so now it's not going to be affected at all but pack it up we did delete it and now it's back and there it is again right so it's actually now listed with that original code so in that blog post we actually combine these into being load and unload so i'm going to make a new one i'm going to delete all the other things so i'm going to call this load unload and really just say this okay so let's go ahead and delete everything else that we just went over and save this one now unload meaning zip all the files in the current directory so this is unloading what's going to be on the server and then loading will be what's reloading on the server later right so we save that and it's only one file and let's go ahead and just rename this now to two just to make sure it's working and now i'm gonna call this load and i run that and it gives me local unload and there it is and it has that original code okay so yeah you could use git you could absolutely get in version control and run run some commands to get but the nice thing about this is all i need to do here is download that tar and now i can just re um upload it or unload it either way so i'm going to go ahead and delete these two things or rather keep the tar and keep load unload and just delete the other one okay so now i just have these two files in here uh so when we actually build our docker container we'll have this load in here uh that will absolutely be able to load that tar and this is going to make a lot more sense once we go into production and i'll show you a few examples of how the docker file or docker containers will fail when we go into production for these notebooks but this was just a simple way to me on how to load and unload all of these things all right looks like i didn't delete every file unpack it is still there so perhaps it's in the load unload i don't know but uh for now we're gonna leave it as this and then we need to create our docker container all right so let's go ahead and create our minimal docker file and this is really minimal so we just we want to come into the root of our project create this new file here and it's just docker file and then we're going to go ahead and use python 3.8 so from python colon 3.8.2 dash slim and then env app underscore home and that's app and then workdir and this is dollar sign at home gotta love vs code and it's code completion there we want to copy everything from the current directory on over and then we're going to go ahead and run pip install pip and pip emv upgrade of course i need pipimv to install my pip file but if you weren't using the pipim v you could totally use a pip file and just run pip install like you know dash r and requirements txt but of course i'm using piping v so this is not relevant for me but i will leave it in case it's relevant for you so pipping me install and then it's just skip dash lock and system so i want it on the whole system and any dev dependencies i may have and then finally i'm going to have a command for my entry point docker loves double quotes so use double quotes that that entry point is going to be in scripts entry point.sh uh since i'm writing this now i'm gonna go ahead and create all of the things for it with the exception of what's actually gonna go in that entry point which if you're familiar with docker it's gonna be super easy as to what's going in there but let's go ahead and just a little bit more with this docker file first and foremost we want to get the smallest possible image we can use so if you're not familiar with docker docker every time you run it and build it it creates an image for you that image can be reused anywhere so i could essentially turn this docker file into a brand new image and call it something different it's called like you know cfe python or something like that which would have all of these things done first right so the python slim image really just narrows down the size of your docker container uh and thus saving a lot of time and building and pushing and doing all sorts of cool stuff so this is that minimal container that we need that's it pretty cool huh so let's go ahead and actually create the entry point now all right so let's go ahead and write out that entire entry point.sh it's just uh hashtag exclamation mark slash bin slash bash and then slash user local or usr local bin jupiter notebook dash dash config equals to well what's the configuration file of course it's in conf and jupiter actually we don't need those quotes there it's redundant okay so this is entry point script that will work inside of docker but may not work on your local system so if we actually activate the piping v shell and try to run this so windows users i'm positive you probably won't be able to run this at all but mac and linux users let's go ahead and try this so cho mod scripts entry or rather entry points.sh of course plus uh cho mod plus x means that we can actually execute this so let's execute it with dot slash scripts and then we get this error right well part of the reason for me is i don't have jupiter on my system as a whole uh so this is not actually where that's located right but when we use the docker file um it's gonna install it globally so this entry point should absolutely work with that of course we need to test that when we build it the next few things are these commands right here of course conf is where jupiter the actual configuration that i created jupiter.pi is and it's dot slash because uh this is going to be in the root of the project right so dockerfile itself is in the root of your project but then it also tells us that we want to work work in the work door dur of app right so when i actually build this docker container we'll take a look at the docker shell itself to see exactly how the code is laid out so it's a little bit more clear in your mind in case it's not right now because if you haven't used docker enough it might not be all right so let's go ahead and build our docker container so it's simple docker build and then we tag it where we want to tag it in my case it's cfv dash jupiter and then the actual docker file that we're going to use which is on the same you know route as this right here and then a period at the end to build the current directory so this should take some time especially if you've never done this before for this tag or for the actual entry you know the image that it's it's inheriting from it could take a good amount of time to actually build this and be fairly large in size potentially as well uh because of what it's inheriting from you might have to build all those things so it's a number of things that it needs to do i'm going to let that finish building and then we'll come right back so while that is building i will add a script in here under my scripts command uh directory called d underscore build.sh so what i like to do is actually keep track of how i build my docker containers more specifically the tag that i end up using for it right so inside of d underscore build i usually add docker build dash t cfe jupiter and then dash f docker file period right so the exact same thing that i just had i bring it into d underscore build.sh and if you're on a windows all i do is d underscore build ps1 ps1 is a powershell command it's essentially like the shell command but this is powershell kind of different but accomplishes the same thing because the docker command line interface is the same across all systems which is super nice uh but now that we've got this built let's actually go ahead and take a look at this inside of the docker container itself so what i want to do is docker run dash it and then the tag itself so cfe dash jupiter and then we'll do bin slash bash okay so what bin slash bash does is it doesn't actually run the entry point instead it allows you to jump into the shell of this project as in the operating system the image it's bringing us in there so we can see what's going on uh notice if i do pwd no matter what system you're on right now you're using a linux server right so if you're on windows this is linux i'm on a mac it's linux so once you run docker run bin bash you're now in a linux server you're in the docker environment uh in this case i have a docker or a linux server running perhaps there's other kinds of servers but for me i'm in a linux server so i can pwd and i see the root of my app here right so it actually has everything um from my local system in here as well which your system may or may not have but while i was building i actually created a couple scripts those aren't in here actually there should be no surprise to that fact because i added the scripts after i ran the command to build it so whenever you make changes to your code you have to rebuild it that's just one of those tenants okay so we have that entry point here right of course if we look at the docker file we see that that is actually being called right obviously and we can call this in the root of our project two and what we see is it being run now if i try to go to this url it's not gonna work there's a part of the reason is because i don't have the actual address of this image and how it's running the other part is this is not how you should run your notebook server anyway so let's go ahead and exit out of here and let's go ahead and run it by creating a new script in here so the g run dot sh so the running script is well it's actually not that hard to do so first and foremost it's docker run and then dash dash env port equals to the port we want to set so i'll explain that in a moment again and then we do dash i t dash p the actual port that we want to expose and the port that we want to run from and cfe jupiter okay so the actual tag itself so we save that and if you're on windows just make a ps1 version cho mod plus x and scripts d-run.sh and scripts d-run.sh okay so this will actually run our jupiter notebook server and of course if i go to this url i'm probably going to get something like this okay so let's go ahead and go into local host now it's running i do want to make sure that i'm using the correct port right or that this is actually coming from docker itself it looks like it is but i'm not positive so let's go into abc and let's create a new file here and i'll just call this another one okay so what we shouldn't see in vs code is a new file called another one in our notebooks folder and if we go in there nothing right so this is the exact reason i print hello and save this this is the exact reason why we have this load unload thing unload will remake it right so we run that and now if i download this actual directory or that tar it will be those original files here right so what we saw on the unload is it actually grabbed and created all those things and now it can actually run and download this and then with that one i would just replace what's currently in there and then we would just repeat that cycle as we make changes so that's actually pretty cool if you ask me we now have a way to build it and run it so oftentimes when i have this command of build and run i'm usually doing both simultaneously so i also create a command called b in r as in build and run or i type out build and run completely but you know i think in the repo you'll see it as build and run um or you just call one called run or just you know come up with your own style whatever it is that you want to do but the idea here is when i'm testing locally i'm going to most likely build it and run it all in one stretch um so there is something cool about vs code is you can actually use the a docker extension so if you look for extensions for docker and then you can remotely connect and remotely build into docker so you can actually code in docker with vs code that's outside the scope of what we're doing here but there you go so we now have pretty much everything we need to do to then now deploy it on to some sort of container running service now my intuition was hey can i bring this to google cloud run which is a serverless application unfortunately jupiter and serverless i don't think work yet because jupiter needs a kernel that's constantly running it needs a server actually running to work correctly so unfortunately cloud run is not a viable option which is why i'm going to be using of course heroku the biggest assumption i have to make is that you have the heroku command line interface installed with the roku cli if you don't definitely go ahead and google how to install that it's really easy so we're going to go ahead and do heroku create and i want to create an application so me just calling heroku create will give me some random url here you can obviously declare the one that you want but i'm just using a random one because this is fairly random of a project okay so this is now the url that i actually want to use inside of my jupyter configuration so i have this allowed origin here let's bring that new one in here protected journey so on and so forth okay so now that we've got that what i want to do then is also run heroku container login so this is a command to allow docker and heroku to work together to actually do the pushes that we need so it's kind of a double log in usually when you actually download the heroku cli you will also have to log into heroku itself so after we have this it's just a matter of pushing and releasing this to heroku which is pretty simple um so we are going to call heroku container push web hit enter now my case is asking for an app because i didn't actually set up git for this particular project so i just need to pass in the dash a and then the app name itself which in my case it's this right here protected journey right so again like when i do the build commands um that we did before right the build sh i also want to do the heroku commands which in this case i'll just call it push and which is going to be that right there okay and then the next one after we push it we just release it okay so notice that it has web so this is a web process this is a standard heroku thing what that's actually looking for is this docker file here there's ways to have more than just web on there and there's ways to customize the docker file itself but that's outside the scope of what we're doing here okay so now that i have push or of course if you're on windows it's going to be push.ps1 okay we want to mac in linux users we've got to do chomod plus x scripts slash push dot sh and then run scripts slash push sh okay so i need to make sure i save everything of course and notice that my virtual environment is not currently activated however it's still building this project the cool thing about this is it's actually building that container image and then pushing it into heroku's container registry where it kind of stores all of your containers related to all of your projects and then finally after you actually do all that it's going to run all of the building as we've already seen from docker and then we are going to actually release it so once you actually release it then you can actually now use what that is which i which i finally did this actually took some time to do uh but if you want to know a little bit more about how heroku runs this take a look at this link right here that will certainly show you a lot more of the options that you have from heroku to actually put these things into production now you may remember i said earlier that this was much more about putting jupiter and docker together and then adding heroku was sort of a bonus here so what we can do is just run heroku open and oh yeah we need to pass in the app name which in my case is just this you know random string here and so this will open up that jupiter notebook server and we go abc which is the password i had which of course now i have load and unload here and i can actually run this right so let's go ahead and call this load we run that and all it does is basically just reload this same file of course this exact same concept could be used for any additional notebooks that you might want to bring on to the server itself this is not going to be the fastest server ever because i didn't provision any resources to it i just made a free one altogether it's not that big of a deal okay so that is pretty much it for the baseline of things now if we actually want to go a little bit further we would actually want to add in additional resources as an additional installations additional packages that we might need for this particular project which is something i certainly want to do all right so go ahead and go to this link right here at the very bottom we have this bonus installs here we also have this code on our repo as well but i want to actually install a few other packages for my project and just show you essentially how easy it is to upgrade your environment for your notebooks so what we want to do is actually install things like numpy pandas opencv or tensorflow because oftentimes when we want these more advanced packages it's really easy to install them and then for machine learning packages we can do inference for sure on a cpu it doesn't actually need a gpu to do inference or predictions we can just use the results of that and then there's other packages like scikit-learn that don't necessarily need a gpu and to actually run well on a cpu as well so this actual docker file installs a bunch of stuff so if you copy this and we're going to bring our old docker file in here i'm just going to rename our old one as dockerfile.og and if you do og you still get syntax highlighting inside of vs code and then i'll go ahead and create another docker file or a new docker file and paste this in here uh with all of the things that i just mentioned okay so we can go line by line and have the things that we want and the things that we don't want or you just have all of this so this command right here this app get update install this is linux level things that are being installed these ubuntu dependencies that are system-wide dependencies that we just need in here the biggest noticeable one is the opencv one so if you wanted opencv to work on this actual project this would be the way to do it and there's a number of other things that you could add in here i think earlier i talked about using curl on that terminal you you could just add in curl like that actually this might be the call itself you'd actually need references you know i forget the exact app get installs all the time so it's easy to just look them up in this case i did that for you i looked all these things up a number of the python 3 things we probably don't need git if you need version control there's how you can actually install it and then inside of your python packages you can use something like git python to have python doing all the get calls for you instead of needing to write shell commands if you don't know how to do that but this right here will actually install a bunch of different things related to computer science or even to machine learning data engineering data science all of that stuff keras tensorflow it's really great um now opencv contrib python is also being installed in conjunction with lib opencv dev now i've found that this is the best combination to make opencv work for sure if you are interested in that psychic learn another great machine learning you know package that you might use but now this is this is what i love about docker files is now you now have the docker file to install all of this stuff wherever you need them to be installed right so if you ever need this on any other project you totally could i just think it's very fitting for a jupiter notebook so how do i actually do this now well what you could do is just run scripts push and what this should do is actually go through our new docker file now right as it's showing you right here and so it's not necessary that you have to install these things locally for your environment as you should see now is there's a lot more installations that are happening on here that you might end up needing to do i said in mutu it's actually debian that just a little mistake just a different linux distribution not that big of a deal but if we scroll up we can also see some of the recommended packages that it's telling you to do recommended packages right here so all of these if you were so inclined you could add as an item in this list that i already have here you don't have to do that but they are recommended by debian in this case for the installation and then all the new packages that are being installed for us like gcc every once in a while with i think it's opencv you get this gcc error dissolves that um so that if you've ever spent any significant amount of time trying to install opencv this script and docker makes it dead simple for opencv in particular uh pytorch is another one of those things that yeah every once in a while you're going to want to install it um and it is additional installations then just a simple tensorflow's a lot easier to install than pytorch is of course adding the gpu adds a layer of complexity that i'm just not going to cover here but as you see we've got another app get call in here really when i actually build these things i put all of the app get calls together i don't actually separate them out but i wanted to leave notes in here for you depending on what you wanted right so you can get rid of that and of course if you're using fastai you definitely need pi torch installed but this i think is really cool for inference now the other aspect of this that i want to mention is our little load unload command this will work for models as well so if you have pickled model files or any other kind of model file h5 model file you can use this exact same thing it will load everything up and then you can unload it once you get into the server and when you actually build your container image this tar file will and be able to come with you so as it relates to heroku is you now don't have to worry about the slug size as you would not using docker so if you actually deploy jupiter as a standard heroku application a non-docker application you'll run into a lot more issues with installation uh because of the size of things docker as far as heroku says there's no size limit which is another benefit to using docker there's just there's just too many too many to count okay so this is going to take significantly longer to actually update and install because i've added just so many things here i'm actually not going to finish adding this i just wanted to mention this is a is a really valuable option for later and of course if you install this docker file on your local system um it's gonna it's gonna eat up a lot of resources which is why i started out with just saying hey let's just do this slim version because that's the bare minimum of what we need and then we can add the things that we want later all right hey thanks so much for watching hopefully you got a lot out of this in the sense that you now have complete control over a jupiter notebook server now me personally i actually use the google colab all the time so that's actually my default for jupiter notebook servers at this point there's a lot more advantages to just spinning that up than this but for those of you who want that granular control or just to learn how to know more things this was a really good example of that i actually think learning this or going through this process is important to better understand both technologies that is jupiter and docker of course there's the added bonus of using heroku to actually get it into production uh but the main thing here is to understand that docker and jupiter are amazing combinations and i actually think that in the near future we'll see a new service out there somewhere that allows this combination to happen and then spinning up our own gpu work costs practically nothing or next to nothing so that you might actually switch back to something like this than google collab because jupiter is still pretty young as a package and i think there's going to be a lot more cool and interesting services that come out as a result so of course if you actually find any please comment below because i would love to check those out like essentially turning this into the same power that collab has and maybe even overcoming some of the challenges of the ephemeral nature that docker combines um so maybe one of those things being persistent volume something that heroku does not have by default for containers but anyways thanks again for watching i hope you got something out of this and i look forward to seeing you next time you
Info
Channel: CodingEntrepreneurs
Views: 8,269
Rating: 5 out of 5
Keywords: djangourlshortcfe2018, install django with pip, virtualenv, Django Web Framework (Software), Mac OS (Operating System), Python (Software), web application development, installing django on mac, pip, django, beginners tutorial, trydjango2017, install python, python3.8, django3.0, python django, web frameworks, install python windows, windows python, mac python, install python mac, install python linux, pipenv, virtual environments, 30daysofpython, beginner python, python tutorial
Id: GoJ6qR2VMTA
Channel Id: undefined
Length: 49min 35sec (2975 seconds)
Published: Tue Jul 21 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.