This is an example of what can be achieved on Nimbus Research Cloud. The detailed configuration for various VM flavours and OS configurations might differ. Nimbus users are responsible for managing their VMs and installing tools. We believe that this step-by-step example might be helpful to run Jupyter Notebook interactively.
On Nimbus, you can run Jupyter Notebook interactively. It requires three main steps:
- Open the 8888 port from your Nimbus dashboard
- Run Jupyter Notebook with an assigned port from an Jupyter container
- Open Jupyter Notebook on port 8888 through your instance IP address
Open port 8888 on Nimbus dashboard
From the Nimbus dashboard:
1. | Navigate to Network > Security Groups: | Image Modified |
2. | Click on + Create Security Group, name it 'port 8888' and then select the Create Security Group button: | Image Modified |
3. | Select + Add Rule: | Image Modified |
4. | Then enter the port number 8888 under 'Port', and click on the Add button: | Image Modified |
5. | Navigate back to Compute > Instances, then click on the arrow down button for the your instance, and select Edit Security Groups. Ensure that you select the port 8888 security group that you have just created, i.e. it should appear on the right hand side list of Instance Security Groups: | Image Modified |
Run the Jupyter Notebook command
On your Nimbus instance terminal:
Pull the Jupyter base notebook container (latest)
Note |
---|
The following command assumes that you have Singularity installed. All Pawsey images have Singularity pre-installed. If you need to install Singularity, see the documentation here. |
Note |
---|
The next step assumes that you already have the /data directory from attaching your storage volume. You may have to set ownership of the /data directory to the user so that you can bind-mount it to the container in the next step: >sudo chown ubuntu:ubuntu /data/ |
Code Block |
---|
>mkdir /data/containers
>sudo singularity pull --dir /data/containers docker://jupyter/basedatascience-notebook:latest |
Run the Jupyter Notebook command as follows
Code Block |
---|
>singularity exec -B /data /data/containers/basedatascience-notebook_latest.sif jupyter notebook --ip='0.0.0.0' --port=8888 --no-browser --allow-root |
singularity exec
invokes the container to run the rserver command.- -B is a flag used to for bind-mounting
/data
, which is a directory on your instance. - You can replace /data with a directory of your choice, as long as it has user ownership.
If you would like to run the notebook in the background and still access it while you are not logged into your instance, run it with 'nohup':
Code Block |
---|
>nohup singularity exec -B /data,/usr /data/containers/basedatascience-notebook_latest.sif jupyter notebook --notebook-dir=/data --ip='0.0.0.0' --port=8888 --no-browser --allow-root &
nohup: ignoring input and appending output to 'nohup.out'
|
You should see an output with how to access the notebook (if run with nohup, the token will be in nohup.out
). Take note of the token, and follow the next step.
Open Jupyter Notebook
- Open up a browser window (IMPORTANT: Firefox does not work. Use Chrome or Safari.)
- Go to http://your-instance-ip-address:8888
- Use the token that is provided from the previous step
- Ensure you are in the folder /data so that all your work will be saved on the /data folder of your instance
Start creating a new notebook and begin your work!
Note |
---|
|
If you have installed modules on your instance, you would need to append your library/module path(s) to add the relevant directory(ies) on your instance, for e.g.: Code Block |
---|
import sys
sys.path.append('/usr/lib/python3.8')
sys.path.append('/usr/local/lib/python3.8') |
|
Note |
---|
|
You may also have a different version of Python on your instance, to the one on the container. Ensure that they are the same versions by updating the one on your instance, or choosing a container that has the same version of Python as the one on your instance. |
To check for current running Jupyter notebooks, run the following:
Code Block |
---|
>singularity exec /data/containers/basedatascience-notebook_latest.sif jupyter notebook list
Currently running servers:
http://0.0.0.0:8888/?token=e2749daaa12d8d9d9029d2cb21be9f9ac8b76264ece50116 :: /data |
To stop the notebook on port 8888:
Code Block |
---|
>singularity exec /data/containers/basedatascience-notebook_latest.sif jupyter notebook stop 8888 |