Jupyter Notebook

Leverage the power of Digital Ocean droplets to deploy a Jupyter Notebook IDE with Jupyter AI in minutes! Whether you’re using Jupyter Lab for data science or machine learning tasks, use this marketplace app to set up a powerful experimentation environment without the hassle of manual installation.

Software Included

Package Version License
JupyterLab + Jupyter 4.2.4 BSD-3-Clause License
Anaconda 2024.06-1 Non-Commercial Use Only

Creating an App using the Control Panel

Click the Deploy to DigitalOcean button to create a Droplet based on this 1-Click App. If you aren’t logged in, this link will prompt you to log in with your DigitalOcean account.

Deploy to DO

Creating an App using the API

In addition to creating a Droplet from the Jupyter Notebook 1-Click App using the control panel, you can also use the DigitalOcean API. As an example, to create a 4GB Jupyter Notebook Droplet in the SFO2 region, you can use the following curl command. You need to either save your API access token) to an environment variable or substitute it in the command below.

curl -X POST -H 'Content-Type: application/json' \
         -H 'Authorization: Bearer '$TOKEN'' -d \
        '{"name":"choose_a_name","region":"sfo2","size":"s-2vcpu-4gb","image": "sharklabs-jupyternotebook"}' \
        "https://api.digitalocean.com/v2/droplets"

Getting Started After Deploying Jupyter Notebook

JupyterLab

JupyterLab is an interactive development environment for working with notebooks, code, and data. It offers a flexible and powerful interface for data science and scientific computing, allowing you to create and share documents that contain live code, equations, visualizations, and narrative text.

Jupyter AI

Jupyter AI extends JupyterLab with capabilities for integrating machine learning and artificial intelligence workflows. It provides tools and extensions to leverage AI models directly within the Jupyter environment, making it easier to incorporate AI into your data science tasks.

Before You Deploy

Consider the following to ensure you choose the right configuration for your needs:

  • Droplet Size: Select a Droplet size with sufficient CPU, memory, and storage based on your data processing requirements.
  • Volume: Attach a Volume to your Droplet if you anticipate working with large datasets or need additional storage space.

Quickly Get Started With Your Jupyter Droplet

  1. Access the Droplet Console:

    • Navigate to the Droplets page.
    • Locate your newly created Jupyter Droplet and click on its name.
    • Under the “Access” tab, select Console. This will open an in-browser terminal session connected to your droplet.
    • Log in as the root user using the password you set during droplet creation.

Droplet Console

  1. Login via SSH (Method 1: Using SSH Key):
  • If you selected an SSH key during droplet creation, follow these steps:- Open your preferred SSH client (e.g., PuTTY, Terminal).
  • Use the droplet’s public IP address to log in as root:
ssh root@your_droplet_public_IP
+ Ensure your SSH key is added to the SSH agent, or specify the key file directly:
ssh -i /path/to/your/private_key root@your_droplet_public_IP
+ Once connected, you will be logged in as the root user without needing a password.
  1. Login via SSH (Method 2: Using Password):

    • If you set a password during droplet creation, follow these steps:- Open your preferred SSH client (e.g., PuTTY, Terminal).
      • Use the droplet’s public IP address to log in as root:
ssh root@your_droplet_public_IP
* When prompted, enter the password you set during droplet creation.- This will log you into the droplet as the root user.
  1. Check the Message of the Day (MOTD) for Jupyter Access Token:

    • Upon successful login via console or SSH, the Message of the Day (MOTD) will be displayed.
    • This message includes important information such as the Jupyter Lab access token. Take note of this token as you’ll need it to log in to Jupyter Lab.

MOTD

  1. Access the Jupyter Lab IDE:

    • Open a web browser and navigate to the URL for your Jupyter Lab instance, which will be http://your_droplet_public_IP.
    • This will bring you to the login page for Jupyter Lab.
  2. Enter the Jupyter Lab Access Token:

    • On the login page, enter the access token that you noted from the MOTD.
    • This token is required for the first login to ensure secure access to your Jupyter Lab environment.

Jupyter Login

  1. Start Using Jupyter Lab:

    • After entering the access token, you’ll be logged into Jupyter Lab’s web-based IDE.
    • You can now start creating, editing, and running Jupyter notebooks directly within your browser.

Access your Anaconda Distribution

  1. Switch to the Anaconda user:

    • Once connected, switch to the Anaconda user by running:
su - anaconda
  1. Checking Your Conda Installation:

    • Start by checking if the conda command is working. If not, run the following command:
/home/anaconda/anaconda3/bin/conda init
* This command will set up the necessary configuration in the ~/.bashrc file. You may need to source ~/.bashrc or exit and run su - anaconda again.
  1. Creating and Managing Conda Environments:- Use Conda to create isolated environments for your projects.

    • To create a new Conda environment, use:conda create --name myenv

    • Activate the environment by running:conda activate myenv

    • Install required packages and libraries within the environment using Conda or pip.

For more detailed instructions and tips on using Conda and Jupyter, refer to the Conda documentation: https://docs.conda.io/

Manually Running the Jupyter Notebook

- Jupyter Notebook is installed under the jupyter environment. You can manage the jupyter-notebook.service provided.

- To check the status of the service, run the following:

sudo systemctl status jupyter-notebook

  • If you want to run Jupyter Notebook instead of JupyterLab, you can manually enter the Jupyter virtual environment by running conda activate jupyter.

  • The droplet already starts up an instance of the Jupyter Notebook on boot. If you need multiple instances, you’ll have to run them up manually by providing port number to have different instances listening on different ports.

    • To manually start Jupyter Notebook, run:
    conda activate jupyter
      jupyter lab
    

Using Jupyter AI

To leverage Jupyter AI in your projects, follow these steps:

  1. Install Jupyter AI extensions:

    • Ensure you are in the Jupyter environment by running:
    conda activate jupyter
    
    • Install Jupyter AI extensions with the following commands:
    jupyter labextension install @jupyterlab/google-drive
      jupyter labextension install @jupyter-widgets/jupyterlab-manager
      jupyter labextension install @jupyterlab/git
    
  2. Configure Jupyter AI:

    • Depending on your specific needs, configure the AI extensions and tools within the JupyterLab interface. This may involve connecting to external AI services or setting up local AI models.
  3. Using AI Models:

    • Once configured, you can use AI models directly within your Jupyter notebooks. For example, to use a pre-trained model for image classification, you might write:
    from keras.models import load_model
      model = load_model('path_to_model.h5')
      result = model.predict(your_input_data)
    
  4. Exploring AI Capabilities:

    • Utilize Jupyter AI’s tools to explore and visualize the outputs of AI models, integrate them into your data workflows, and share your findings with others through interactive notebooks.

Example 1: Running Stable Diffusion

Note: If you have small compute, skip this and go to Example 2. Running this on <16 vCPU may cause the process to be killed.

To run the “stable diffusion 1.5” model, ensure your Droplet meets the following specifications:

  • CPU: At least 16 cores
  • RAM: At least 32GB
  • Droplet Type: Premium CPU-optimized (Xeon series 3)

Commands:


su - anaconda  



cd examples/stable\_diffusion.openvino/  



conda activate stable-diffusion-1.5  



python demo.py --prompt "Beautiful lake, sunset, and a mountain"

The output is stored in output.png. If connected to Jupyter notebook, you should be able to view the file in the notebook itself.

Example 2: Running DistilBERT Sequence Classification

This tutorial guides you through running the DistilBERT sequence classification in a JupyterLab environment.

  1. Navigating to the Notebook:

    • In JupyterLab, navigate to:
    /home/anaconda/examples/openvino_notebooks/notebooks/229-distilbert-sequence-classification
    
    • Open the 229-distilbert-sequence-classification.ipynb notebook.
  2. Selecting the Kernel:

    • From the “Kernel” menu, select “Change Kernel”, and then select “openvino notebooks”.
  3. Running the Notebook:

    • Run the cells in the notebook, which will download and optimize the model for better performance and execute sentiment analysis on sample texts.

Note: If you encounter the “mo command not found” error, replace mo with its full path: /home/anaconda/.conda/envs/openvino_notebooks/bin/mo.

Troubleshooting

If you encounter issues, refer to the following resources:

  1. Disk Usage: Example files and Conda environments take up significant space. Clean up disk space by following instructions in the save-9GB-by-deleting-examples file in the /home/anaconda directory.
  2. Conda Command: If the Conda command is not working, run:

/home/anaconda/anaconda3/bin/conda init
  1. Jupyter Notebook Service: Check the status of the Jupyter Notebook service by running:

sudo systemctl status jupyter-notebook  
  1. Multiple Jupyter Instances: For multiple instances, provide different port numbers.

Refer to the Conda cheat sheet for a list of commands: Conda Cheat Sheet

Inspect the source Packer files of this image at: DigitalOcean Droplet 1-Clicks GitHub