Skip to content

Scheduling Jobs

NCShare uses the Slurm Workload Manager to run work on its compute nodes. Connect to the cluster with SSH or an OnDemand shell, then use Slurm to start an interactive session or submit a batch job. See Partitions to choose where your job runs.

Running an interactive session

An interactive session gives you a shell on a compute node, for testing, debugging, or running work you want to watch. Request one with srun,

$ srun -p common --pty bash -i

When the session starts, your prompt moves to a compute node. Add -c, --mem, and -t to request CPUs, memory, and time, for example srun -p common -c 4 --mem=16G -t 2:00:00 --pty bash -i. For a short session with higher priority, use the interactive partition. Type exit to end the session and release the resources.

You can also run a container inside an interactive session. The following commands start a shell in the Apptainer image Apptainer.sif, which lets you interact with the environment as if it were a virtual machine.

$ srun -p common --pty bash -i
$ apptainer shell Apptainer.sif

Apptainer> cat /etc/os-release

PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.3 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo

Submitting a batch job

Users may submit batch jobs through the Slurm scheduler using a batch script such as the one below.

jobscript.sh
#!/bin/bash
#SBATCH -J job_name          # Job name
#SBATCH -p common            # Partition name

cd $SLURM_SUBMIT_DIR
echo "Running on host `hostname`"

If more control is needed over the job parameters, additional SBATCH directives may be added to the script as shown below.

jobscript.sh
#!/bin/bash
#SBATCH -J job_name          # Job name
#SBATCH -p common            # Partition name
#SBATCH -N 2                 # Total no. of nodes
#SBATCH --ntasks-per-node 64 # Tasks per node
#SBATCH --mem=500G           # Memory per node
#SBATCH -t 02:00:00          # Time limit hrs:min:sec

cd $SLURM_SUBMIT_DIR
srun -n $SLURM_NTASKS aims.x > aims.out 2> aims.err

Instead of specifying -N and --ntasks-per-node, users may specify -n to set the total number of tasks for the job. Slurm will then allocate the required number of nodes based on the tasks requested and the default tasks per node for the partition.

For running GPU Slurm batch jobs, please refer to the GPU documentation.

To submit the batch job script, use the sbatch command as shown below.

$ sbatch jobscript.sh

You can monitor the status of your job using the squeue command,

$ squeue -u $USER

The sample job script below (slurm_apptainer.sh) illustrates how to use Apptainer as part of a batch session. All defaults for number of nodes, time etc. are used here.

slurm_apptainer.sh
#!/bin/bash
#SBATCH --job-name=slurm_apptainer
#SBATCH --partition=common

cd $SLURM_SUBMIT_DIR
apptainer exec /opt/apps/containers/users/simple_image.sif cat /etc/os-release

Submitting the batch script,

$ sbatch slurm_apptainer.sh

Submitted batch job 459436

The output of the job can be found in the file slurm-<jobid>.out as shown below,

$ cat slurm-459436.out

PRETTY_NAME="Ubuntu 24.04.3 LTS"
NAME="Ubuntu"
VERSION_ID="24.04"
VERSION="24.04.3 LTS (Noble Numbat)"
VERSION_CODENAME=noble
ID=ubuntu
ID_LIKE=debian
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
UBUNTU_CODENAME=noble
LOGO=ubuntu-logo