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.
- DigitalOcean account: Followers will need to sign up for DigitalOcean to follow along
- Visual Studio Code: We are going to leverage this application to view the Jupyter Notebooks running on our cloud machine on our local window
- Basic shell scripting: Users will need to enter commands into their terminal to follow along
On your local machine, we are going to need to do two things:
- Set up our SSH Key if it hasn’t been done yet. Follow this tutorial to create a new one, and add it to the DigitalOcean account you plan to use
- Download VS Code: VS Code is our favorite code editor tool, especially because of its built in capabilities around handling SSH pipelines. With VS Code, we can open our remote Jupyter Notebook window on our local browser with ease
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:
- Select a datacenter region closest to you, and the default VPC network
- Choose the “AI/ML Ready” OS template, this is essential to making the GPU work with the CPU
- Select a single H100 GPU or 8x machine. To follow along, only a single H100 is required
- Create or select an existing SSH key to connect with your machine. Follow this tutorial to create a new one. This must be done before starting the Droplet if we want to access the full tutorial
- Name your machine something unique
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@
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 switvch to it with the following command.
useradd -m -g users
su
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@
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!