Jupyter Labs with Cudo Compute

Prerequisites

  • Create a project and add an SSH key
  • Optionally download CLI tool
  • Choose a VM
  • For GPU VMs use the Ubuntu 22.04 + Nvidia drivers + Docker image (in CLI tool type -image ubuntu-nvidia-docker)
  • For non-GPU VMs use the Ubuntu 22.04 + Docker image (in CLI tool type -image ubuntu-2204-docker)

Jupyter in a Docker container

The fastest way to get started with Jupyter is to use the official Jupyter Docker image. This image contains JupyterLab as well as all of its dependencies. You can find the Docker image on Docker Hub and the source on GitHub.

There are several Jupyter images to choose from, starting with the most minimal:

jupyter/base-notebook includes conda and mamba (a faster alternative to conda) but no other scientific Python packages.

jupyter/minimal-notebook adds TeX Live, git, vi, nano, tz data and unzip

jupyter/r-notebook everything in minimal plus the R interpreter, IRKernel plus additional packges

jupyter/scipy-notebook everything in minimal, plus packages including scipy, scikit-learn, pandas, matplotlib

jupyter/tensorflow-notebook everything in scipy-notebook plus TensorFlow machine learning framework

jupyter/datascience-notebook everything in scipy-notebook and r-notebook plus additional packages for data science

Let's start the minimal notebook, SSH into your VM and run the following command:

docker run \
-it --rm -p 8888:8888 \
--user root \
-e CHOWN_HOME=yes -e CHOWN_HOME_OPTS='-R' \
-v /jupyter:/home/jovyan jupyter/minimal-notebook

This yields:

 To access the server, open this file in a browser:
        ...
     or http://127.0.0.1:8888/lab?token=626217ed7607331b9523cb2d55aa72ea4dd044e4020d21e1

Replace 127.0.0.1 with the public ip address of your VM, and open the URL in your browser.

Secure Jupyter Server

In this example we will start a jupyter notebook that is secured with a password and HTTPS.

On the console click 'create a VM' in the configure page select your VM CPU, memory and storage requirements. Select Ubuntu 22.04 + Nvidia drivers + Docker as the OS image. This image has Docker preinstalled.

At the bottom of the configure VM form there is a field for a startup script. This script will run when the VM boots. Modify the script below and paste it into the field:

docker run --rm --env=GEN_CERT=yes -p 8888:8888 quay.io/jupyter/base-notebook \
    start-notebook.py --PasswordIdentityProvider.hashed_password='argon2:YOUR-PASSWORD-HASH'

To generate your password hash, decide on a password Generate a hashed password using argon2 algorithm

https://argon2.online

Enter your password as the text input.

  • Salt: press cog
  • Parallelism: 8
  • Memory Cost: 10240
  • Iterations: 10
  • Hash length: 32
  • Algorithm: Argon2id

As an example using 'jupyter-password' as the password results in the following hash: $argon2i$v=19$m=10240,t=10,p=8$WmFncVVsaWNCOU5JMVljeA$Q3FoNfHnaxNdvXyuYTa/zljeq110rIiyMezjHatvExY

The startup script to would look like this:

docker run --rm --env=GEN_CERT=yes -p 8888:8888 quay.io/jupyter/base-notebook \
    start-notebook.py --PasswordIdentityProvider.hashed_password='argon2:$argon2i$v=19$m=10240,t=10,p=8$WmFncVVsaWNCOU5JMVljeA$Q3FoNfHnaxNdvXyuYTa/zljeq110rIiyMezjHatvExY'

The VM will download and run the docker image, this may take a few minutes as they are fairly large. After a few minutes go to https://VM-IP-ADDRESS:8888/lab, there will be a security warning in your browser to bypass as the certificate is self signed. Once bypassed use your password to unlock the Jupyter Notebook.