JupyterLab

Tips for using JupyterLab on Nuvolos

Long-running notebooks

If running notebooks via Jupyter, we recommend submitting the notebooks for computation using papermill and specifying an explicit logfile when executing from the Jupyter terminal. This way you can disconnect from the Jupyter application and the notebook execution can continue whilst be able to monitor run progress.

papermill --stdout-file /files/my_job.out --stderr-file /files/my_job.err NOTEBOOK_PATH [OUTPUT_PATH]// Some code

Note that your Jupyter notebook wil only receive cell output updates as long as the notebook is kept open in the browser. If you reopen a notebook that is still calculating in the background, you won't receive cell output updates. This is standard Jupyter behavior, unrelated to Nuvolos. This is one of the reasons why using tools like Papermill makes sense for long-running notebooks.

Adding a new launcher

In some cases it might be useful to have multiple conda environments inside a single JupyterLab application and be able to launch notebooks from the JupyterLab launcher with kernels that run in these environments. We recommend that the kernel specification associated with the new conda environments created is always installed into the base conda environment (and not user / system prefix) to make sure that the kernel/launcher will function well after distributing an application. Our examples below follow this convention. If you don't want to share the application, then you can also follow instructions from other sources where typically the kernel specification is installed into the user home directory. The following can be done from a JupyterLab terminal and shortly afterwards a new Launcher should appear.

Python

In this case we recommend to create a new conda environment and install a launcher into the environment as following:

conda create env --name my_new_env

conda activate my_new_env

conda install ipykernel

ipython kernel install --prefix=/opt/conda --name "My New Env"

R

In this case we recommend to create a new conda environment and install a launcher into the environment as following:

conda create env --name my_new_env

conda activate my_new_env

conda install r-recommended r-irkernel

R -e 'IRkernel::installspec(prefix="/opt/conda")'

Julia

Once you have a working Julia installation, execute the following command in Julia REPL:

Accessing a local webserver in the browser

Some Python tools run as local web servers and need to be opened in a browser. In Nuvolos, these services must be exposed through Jupyter Server Proxy rather than by connecting directly to a port from your local browser. The example below uses Tensorboard.

  1. Use a JupyterLab application with version later than 3.0.0.

  2. Install TensorBoard:

  3. Install Jupyter Server Proxy if it is not already available:

  4. Create /opt/conda/etc/jupyter/jupyter_server_config.py with:

  5. Restart the Nuvolos application. After restart, a new TensorBoard launcher appears in the Notebook section of the JupyterLab launcher.

  6. Run your TensorFlow job and note the output directory, for example /tmp/my_fit_1.

  7. Create a symbolic link so TensorBoard reads from that run directory:

    If /files/tensorboard_logdir already exists, remove it first with rm /files/tensorboard_logdir.

  8. Open the TensorBoard launcher in JupyterLab. TensorBoard opens using the linked log directory. To inspect a different run, update the symlink and launch it again.

If the server application takes a lot of time to start, you might need to increase the timeout value in the example, otherwise you'll need to refresh the page periodically until the server starts.

Creating a ploty dash application from a notebook

Make sure you have the following packages installed (we suggest to do this via conda from the conda-forge channel).

  • plotly

  • dash

Once these are installed, install the JupyterDash extension:

After this you need to make sure that your dash application has the following logic in it:

Note that this procedure relies on the dash application being run in the context of a notebook.

Real-time kernel resource usage monitoring

JupyterLab supports real-time resource monitoring through the jupyter-resource-usage extension. Install it with:

Restart the Nuvolos application after installation. A new metering icon appears in the right sidebar. When a notebook tab is active, the panel shows CPU and RAM usage for the attached kernel, together with host-level CPU and RAM utilization.

This extension requires IPyKernel 6.10.0 or later, so it may not work in older JupyterLab versions.

Matplotlib plots with LaTeX

To render matplotlib labels and other text with LaTeX, install a LaTeX environment and the required packages:

  1. Install the TeX packages required by matplotlib: ​tlmgr install type1cm cm-super underscore dvipng

  2. Configure your notebook's environment as described in the linked setup instructions.

  3. Run the notebook cell again with usetex=True.

Was this helpful?