Jupyter Notebook

This Droplet 1-Click is pre-installed with Conda and Jupyter, providing you with a streamlined environment for data science and machine learning tasks. Conda allows you to easily manage software packages and create isolated environments, while Jupyter provides a web-based interface for interactive coding and data exploration. With this image, you can quickly set up a powerful data science environment without the hassle of manual installation.

Software Included

Package Version License
JupyterLab + Jupyter 4.0.1
Miniconda 23.1.2

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

Before You Deploy

Before deploying this Droplet, consider the following guidance to ensure you choose the right configuration for your needs:

  • Droplet Size: Depending on your data processing requirements, select a Droplet size that offers sufficient CPU, memory, and storage resources. Consider the complexity and scale of your projects when making this decision.
  • Volume: If you anticipate working with large datasets or require additional storage, it is recommended to attach a Volume to your Droplet. This will provide you with the necessary space to store and access your data conveniently.

Software Versions

This Droplet comes with the following software versions pre-installed:

Getting Started with Jupyter

After deploying the Jupyter Droplet, follow these steps to get started:

  1. SSH into your Droplet:

    • Use your preferred SSH client to connect to your Droplet.
  2. Switch to the Ubuntu user:

    • Once connected, switch to the Ubuntu user by running the following command:
su - ubuntu
  1. Accessing the Jupyter Notebook:

    • You can access the Jupyter Notebook by starting it manually or using the provided notebook.sh script.
    • To manually start Jupyter Notebook, run the following command:
conda activate jupyter
jupyter lab
* Alternatively, you can use the `notebook.sh` script by executing:
./notebook.sh
* The script will handle starting the JupyterLab instance for you.
  1. Creating and Managing Conda Environments:

    • Once you have accessed the Jupyter Notebook, you can use Conda to create isolated environments for your projects.

    • To create a new Conda environment, use the following command: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, please refer to the Conda documentation: https://docs.conda.io/

Example 1: Running Stable Diffusion

If you have small compute, skip this and go to example 2. If you run this on <16 vCPU, the process will likely get killed.

Source: Link

A sample application included with this Droplet is the “stable diffusion 1.5” model. To run this application, ensure that your Droplet meets the following specifications:

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

Please note that running the “stable diffusion 1.5” model can be computationally intensive. In our tests, it takes approximately 1 minute to generate a single image. Commands:

su - ubuntu # if you have not switched to ubuntu user already
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 file. If you have connected to Jupyter notebook, you should be able to view the file in the notebook itself.

Example 2: Running DistilBERT Sequence Classification

Source: Link

Intel maintains a number of sample applications that you can try out and customize. These applications have been optimized to work on Intel hardware. Note that some of these may need a GPU and will not work on CPU.

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

Follow the steps below:

  1. Navigating to the Notebook:

    • In your JupyterLab client, navigate to the following directory:
/home/ubuntu/examples/openvino_notebooks/notebooks/229-distilbert-sequence-classification
* Open the `229-distilbert-sequence-classification.ipynb` notebook.
  1. Selecting the Kernel:

    • Look at the top-right corner of your JupyterLab interface; the current kernel (or Python environment) should be displayed. If it shows “jupyter”, you need to change it.
    • From the “Kernel” menu, select “Change Kernel”, and then select “openvino notebooks”. This ensures that your program runs in the correct virtual environment.
  2. Running the Notebook:

    • Now you are ready to run the cells in the notebook. As you do so, the notebook performs the following operations:- Downloads the original model from Huggingface.
      • Optimizes the model for better performance.
      • Executes sentiment analysis on several sample texts.

NOTE:

During the optimization step, you may encounter an error stating “mo command not found”. This issue is known to us and can be resolved by replacing mo with its full path: /home/ubuntu/.conda/envs/openvino_notebooks/bin/mo. The permanent fix would be to update the path in the conda activation script.

The sentiment analysis typically takes around 0.1 seconds, demonstrating the efficiency of the model on CPU.

Troubleshooting

If you encounter issues during the process, you can refer to the following resources:

  1. README file: Check the Readme.txt file located in the /home/ubuntu directory. It contains common tips and potential solutions for frequently encountered issues.
  2. Disk Usage: Note that the example files take up approximately 500MB, and the Conda environments require about 9GB. Also downloaded models can add up to 10’s of GB. If these files and environments are not needed, you can free up disk space with a few simple commands.

Refer to the save-9GB-by-deleting-examples file in the /home/ubuntu directory for instructions on how to perform this cleanup.