SCRP nodes have Julia 1.5-1.10 installed.

Basics

To use Julia in console mode, type in a terminal:

julia

To run a Julia script, type:

julia file_path

Using Julia on JupyterHub

You can add Julia to JupyterHub by executing the following code snippet within Julia:

using Pkg
Pkg.build("IJulia")

Installing Additional Packages

First, create a new environment or activate an existing environment:

using Pkg
Pkg.activate("environment_name")

Now you can install new packages as needed:

Pkg.add("package_name")

Switch between Different Julia Versions

You can switch between different Julia versions in a terminal using Environment Modules. Follow the instructions here.

Running on a Compute Node - Short Duration

You should run your job on a compute node if you need more processing power.

Jupyter Notebooks

To run Jupyter notebooks on a compute node, following the instructions here.

Julia Console

To run Julia on a compute node in a terminal, simply prepend compute:

JULIA_NUM_THREADS=4 compute julia 

This launches Julia on a compute node with four logical CPUs and 8GB of RAM, for a duration of 24 hours. Note that it is necessary to set the environment variable JULIA_NUM_THREADS to the number of logical CPUs you are requesting, otherwise Julia will default to using a single thread. You can check the number of threads Julia is using by typing in Julia:

Threads.nthreads()

If you need GPU, prepend gpu instead:

JULIA_NUM_THREADS=4 gpu julia

To check if a GPU is truly available, type in Julia:

using CUDA
CUDA.deviceid()

This will return a number if a GPU is available and return error otherwise.

You can request more logical CPUs with the -c option, more memory with the --mem option, more time with the -t option and specify GPU model with the --gpus-per-task option. For example, to request 16 CPUs, 40G of memory and one RTX 3090 GPU for three days:

JULIA_NUM_THREADS=16 compute -c 16 --mem=40G --gpus-per-task=rtx3090 -t 3-0 julia

See compute for a full list of options, or srun and sbatch for maximum flexibility.

Running on a Compute Node - Long Duration

Codes that take a long time to run is best initiated through Slurm’s sbatch command, which allows you to submit a job without the need to wait for it to execute. Your code will run even if you disconnect from the cluster.

First create a script, hypothetically named my_job.sh:

#!/bin/bash
#SBATCH --job-name=my_sid
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=2
JULIA_NUM_THREADS=2 julia file_path

The #SBATCH comments specify various options. In this example, we are requesting two logical CPUs for a single task.

Now submit your job:

sbatch my_job.sh

Subject to available resources, your code will run even if you disconnect from the cluster. The maximum job duration is 5 days.