This page explains how to submit jobs to the Slurm cluster using sbatch, including common options and best practices.
sbatch is used to submit batch jobs to Slurm.
A batch job runs non-interactively based on instructions defined in a job script.
Jobs submitted with sbatch:
An sbatch script is a shell script with Slurm directives.
Example file: job.sbatch
#!/bin/bash
#SBATCH --job-name=example-job
#SBATCH --partition=cpu
#SBATCH --ntasks=1
#SBATCH --cpus-per-task=4
#SBATCH --mem=8G
#SBATCH --time=00:30:00
#SBATCH --output=job_%j.out
#SBATCH --error=job_%j.err
echo "Job started on $(hostname)"
echo "Running as user: $(whoami)"
#SBATCH --job-name=myjob
Sets a readable name for the job.
#SBATCH --partition=cpu
Available partitions:
cpugpu3060gpu4090poc#SBATCH --ntasks=1
#SBATCH --cpus-per-task=8
Use this for multi-threaded programs.
#SBATCH --mem=16G
Request memory per job.
⚠️ Jobs exceeding memory limits may be terminated.
#SBATCH --time=02:00:00
Format: HH:MM:SS
⚠️ Jobs exceeding the limit will be stopped automatically
For GPU jobs:
#SBATCH --partition=gpu4090
#SBATCH --gres=gpu:rtx4090:1
For multiple GPUs (gpu3060):
#SBATCH --partition=gpu3060
#SBATCH --gres=gpu:rtx3060:2
#SBATCH --output=job_%j.out
#SBATCH --error=job_%j.err
%j is replaced with the Job ID.
Submit the job script using:
sbatch job.sbatch
Example output:
Submitted batch job 12345
squeue -u <username>
Check job details:
scontrol show job 12345
scancel 12345
Cancel all jobs of a user:
scancel -u <username>
#SBATCH --partition=cpu
#SBATCH --cpus-per-task=8
#SBATCH --mem=32G
#SBATCH --time=04:00:00
#SBATCH --partition=gpu4090
#SBATCH --gres=gpu:rtx4090:1
#SBATCH --time=08:00:00
#SBATCH --partition=poc
#SBATCH --time=00:05:00
poc--gres