Using Slurm

Slurm is used to manage jobs on the workstation.

Please use Slurm for long-running or computationally intensive work.

1 Check node status

sinfo

Example output may show:

PARTITION AVAIL  TIMELIMIT  NODES  STATE NODELIST
compute*     up   infinite      1   idle mod-linux-ws01

2 Check running jobs

squeue

Show only your jobs:

squeue -u $USER

3 Submit a job

Create a job script, for example job.sh:

#!/bin/bash
#SBATCH --job-name=my-job
#SBATCH --cpus-per-task=1
#SBATCH --mem=2G
#SBATCH --output=my-job.out

hostname
date

Submit the job:

sbatch job.sh

4 Cancel a job

scancel JOBID

Replace JOBID with the job ID shown by squeue.

5 Interactive job

Use this when you need an interactive shell with allocated resources:

srun --cpus-per-task=4 --mem=8G --pty bash

6 Request CPUs

#SBATCH --cpus-per-task=4

Use more CPUs only if your program can actually use them.

7 Request memory

#SBATCH --mem=8G

If a job fails because of memory, increase this value.

8 Output files

This line writes job output to a file:

#SBATCH --output=my-job.out

For error output:

#SBATCH --error=my-job.err

9 Check job details

scontrol show job JOBID

10 Good Slurm habits

  • do not request all CPUs unless necessary
  • do not request excessive memory
  • save output files clearly
  • check logs after jobs finish
  • cancel jobs that are no longer needed