In this tutorial, we are going to walk through all the required steps to setup a Jupyter Lab or Jupyter Notebooks instance on a DigitalOcean GPU Droplet. Additionaly, we will cover some of the essential tips and tricks for setting up and using the Jupyter Notebook to run Deep Learning code.
Jupyter is one of the premiere tools for running Machine Learning, Deep Learning, Data Science, and Python code in general. It is increasingly common for new ML/DL/AI coders to do work within Jupyter Notebooks, especially during the data exploration phases of a workflow. Jupyters unique design with sequential code boxes makes it ideal for practicing core ML skills as well.
Readers can expect to leave this tutorial with a full understanding of how to setup their environment for running Deep Learning code on a Jupyter Notebook on DigitalOcean.
On your local machine, we are going to need to do two things:
Leave the blank window for now, and return to your browser.
Starting a new GPU Droplet is simple. Follow the instructions on the setup page to create a new one. Then follow these steps:
Once these steps are complete, you can create the machine using the prompt on the right side of the window. Be sure to consider any costs this may incur to your account if you continue from this step. With that, our machine setup is complete. We can now begin setting up our local machine environment while the Droplet spins up.
Now that our GPU Droplet is setup, we can SSH in from our local terminal window. Copy the IPv4 address at the top of the Droplet home page, and paste it into the command below to access the machine this way.
ssh root@<your IPv4 address here>
Paste this command into your local browser, and type yes if prompted about the fingerprint. This will connect you to your machine.
The first thing we need to do once logged in is change out of the root user. To do this, create a username for yourself and switch to it with the following command.
useradd -m -g users <your username>
su <your username>
bash
You will likely need to re-open the bash shell at this step.
Next, we are going to navigate to the directory we are going to do our work in from our starting position at the root directory. In the same step, we will also install both Python and Jupyter. This install is relatively fast.
cd ../home
apt install python3-pip python3.10-venv
pip3 install jupyterlab
From here, everything is ready and setup to run the Jupyter Notebook.
Launching Jupyter is the quickest step in the entire process. Simply enter the following command into your remote terminal.
jupyter lab
This will return three values, 1 file path and 2 urls. Copy one of the URLs for the next step.
Open VS Code up to a blank window on your local. In the center of the page, there should be a clickable button that says “Connect to”. This will open a prompt at the top of the search bar at the top of the window. Click “Connect to Host”, and then “+ Add New SSH Host…”. This is where your will paste your ssh key to connect VS Code to your remote machine. Paste the exact same command as we did earlier, repeated below
ssh root@<your IPv4 address here>
This will allow VS Code to remotely listen and interact with our GPU Droplet from our local machine.
The final step to open Jupyter on our local browser is to type “Command” + “Shift” + “P” together in the now connected VS Code welcome page. Search for the “Simple Browser” and open a new window.
In the URL Bar that now appears, paste the URL in. Click the open button on the far right of the URL bar to now open the Jupyter Notebook in your local browser.
This should open the Jupyter Labs environment in our local browser! From here, we are free to interact with Jupyter to do our AI, ML, and data science coding.
Jupyter is the premiere learning and exploration tool for data science, data engineering, and AI research. We hope that this tutorial helps users take advantage of the powerful GPUs available on the cloud to do their work on their local machines with little to no hassle for setup.
Sign up to access the new DigitalOcean GPU Droplets today!
Thank you for reading!
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!