Slurm - SBATCH Header / Flag Cheat Sheet

Overview

There are dozens of possible SBATCH headers/flags for fine-tuning the way a job runs. The most common options are listed here. See all possible options with the shell command: man sbatch or man salloc or visit the official Slurm documentsion for sbatch and salloc.

Table

Option

Examples

Usage

Option

Examples

Usage

-N <X>

 

interactive -N 1

#SBATCH -N 2-3

 

Request a specified or range of nodes for job to be spread across. If omitted, Slurm will run on any number of nodes the job can fit on. It is recommended to set this to 1 unless you have an MPI job

No Default value

-n <X>

 

interactive -n 1

#SBATCH -n 4

The number of tasks assigned to your job. A task is a ‘slot' a process can attach to. This should be 1 for serial jobs, and greater than 1 for MPI jobs

Defaults to 1 if not defined

-c <X>

interactive -c 4

#SBATCH -c 1

The number of cores per task assigned to your job. This should be 1 or greater for serial jobs, and typically is 1 for MPI jobs.
Defaults to 1 if not defined

--mem=<X>G

interactive --mem=4G

#SBATCH --mem=256G

Request a specified amount of memory for your job. Be sure to include G to specify the proper units, otherwise size will be in bytes. ( --mem=4 will allocate 4 bytes, while --mem=4G will allocate 4 GiB)

Defaults to 2GiB per CPU core

-t <time>

 

interactive -t 0-4

interactive -t 60

#SBATCH -t 0-04:00:00

The time limit, aka wall time, for a job to run. This can be in the format minutes, days-hours, or DD-HH:MM:SS.

Defaults to 4 hours if not set

-p <partition>

interactive -p general

#SBATCH -p htc

The partition to submit the job to. See more information about partitions here: ##TODO Link to Paritions

Defaults to HTC if not set

-q <qos>

interactive -q public

#SBATCH -q grp_mylab

The QoS to submit the job to. See more information about QoS’s here: ##TODO Link to qos

Defautls to public if not set

--gres / -G

interactive -G 1

interactive -G v100:1

#SBATCH --gres=gpu:a100:2

Gres stands for Generic Resources, we are only currently using this as a way to request GPU’s. You can specify a type of GPU, or use just a number to request any type of GPU

Defaults to none if not defined

-o <filename>

#SBATCH -o %j.out

#SBATCH -o ~/logs/slurm-%j.out

The output file that stdout is directed to for your job script. Can be a relevant path or absolute path. This is extremely useful for troubleshooting when a job fails, and also for seeing the output of the job. %j is translated to the jobID. See here for more info

Note: the outfile and error file can be the same file

Defaults to %j.out

-e <filename>

#SBATCH -e ~/logs/slurm-%j.out

The error file that stderr is directed to for your job script. Can be a relevant path or absolute path. This is extremely useful for troubleshooting when a job fails, and also for seeing the output of the job. %j is translated to the jobID. See here for more info

Note: the outfile and error file can be the same file

Defaults to %j.err

--mail-type=<$VAR>

#SBATCH --mail-type=ALL

#SBATCH --mail-type=NONE

#SBATCH --mail-type=END

This option defined what notifications you receive about the job. Valid options are: NONE, BEGIN, END, FAIL, REQUEUE, ALL

Defaults to NONE

--mail-user=<$VAR>

#SBATCH --mail-user=%u@asu.edu

 

The user to send the job notifications to. %u translates to your asurite. Can be in the format %u@asu.edu to receive email notifications

Defaults to NONE

 

Additional Help