Running JupyterLab at HPC2N - Julia

Running JupyterLab at HPC2N - Julia

For how to use Jupyter notebook in general, see the Using Jupyter at HPC2N page.

1) In order to use Julia kernels in a Jupyter notebook you need to install the IJulia package in Julia. First load the modules for JupyterLab and Julia (v. 1.8.5 in this case):

module load GCC/10.3.0 JupyterLab/3.2.8
module load Julia/1.8.5-linux-x86_64

2) Then, start a Julia session and add the IJulia package either in Julian mode:

$julia 
using Pkg 
Pkg.add("IJulia") 
Pkg.build("IJulia") 

 

or in package mode

$julia 
julia>] 
(v1.8) pkg>add IJulia
(v1.8) pkg>build IJulia

3) Once this package is installed, write a submit file to start a JupyterLab (in batch mode) using this template: 

Example, loading JupyterLab/3.2.8, its prerequisites, and the Julia version 1.8.5 :

#!/bin/bash
# Here you should put your own project id
#SBATCH -A hpc2nXXXX-YYY
# This example use 1 core
#SBATCH -n 1
# Ask for a suitable amount of time. Remember, this is the time the Jupyter notebook will be available! HHH:MM:SS.
#SBATCH --time=05:00:00

# Clear the environment from any previously loaded modules
module purge > /dev/null 2>&1

# Load the module for JupyterLab
module load GCC/10.3.0 JupyterLab/3.2.8

# Load the Julia module
ml Julia/1.8.5-linux-x86_64

# Start JupyterLab
jupyter lab --no-browser --ip $(hostname)

 

See here for an explanation of the options to jupyter.

4) Submit the above submit file (here I named it MyJupvenv.sh).

sbatch MyJupvenv.sh

You get the <job-id> when you do the above command.

Check the SLURM output file (slurm-<job.id>.out); grab the URL with the hostname as described in the first part of this document, since the localhost one requires you to login to the compute node.

5) Start a web browser within HPC2N (ThinLinc interface). Put in the URL you grabbed, including the token.

6) Inside JupyterLab, start the new Julia kernel. Just click the launcher for that one if no other kernel is running. Notice that besides the Julia version 1.8.5, other options are provided for the kernel of Julia but only the one that matches the loaded module in step 1 will be available.

If a kernel is running (shown under kernels), then shut down that kernel and click "Kernel" in the menu, and then "Change kernel". Pick your kernel from the drop-down menu.

7) You can now run your files etc. with the Julia kernel.

NOTE! Sometimes it is still running on the default kernel. If so, Click the 3 little dots in the right side of the editor-window for the program and pick your kernel. Then rerun your files.

Updated: 2024-04-11, 12:28