SLURM Script Syntax
Last Updated 2018-11-16
References
- Full online SLURM documentation
- UVA ARCS’s introduction to SLURM
Template
#!/bin/bash
#SBATCH --nodes=2 # number of nodes (computers) to use
#SBATCH -N 2
#SBATCH --ntasks-per-node=20 # number of processes to run per node
#SBATCH --ntasks=1 # number of processes to run
#SBATCH -n 1
#SBATCH --mem=4000 # memory to use in MB
#SBATCH --mem-per-cpu=100 # memory to use per CPU in MB
# (cannot use with --mem)
#SBATCH --cpus-per-task=1 # number of CPUs (cores) per process
#SBATCH -c 1
#SBATCH --time=1-12:10:00 # amount of time for the whole job d-hh:mm:ss
#SBATCH -t 1-12:10:00
#SBATCH --partition=standard # the queue/partition to run on
# (standard/parallel/largemem)
#SBATCH -p standard
#SBATCH --output=myResults.out # file for saving standard output
# Note: by default, both standard output
# and standard error goes to slurm-<jobid>.out
#SBATCH -o myResults.out
#SBATCH -o myjobs.%A_%a.out
#SBATCH --error=myResults.err # file for saving standard error
# Note: by default, both standard output
# and standard error goes to slurm-<jobid>.out
#SBATCH -e myResults.err
#SBATCH -e myjobs.%A_%a.err
#SBATCH --account=blabber # the account/allocation to use
#SBATCH -A blabber
#SBATCH --mail-user=<email> # address to e-mail
#SBATCH --mail-type=<type> # send e-mail on certain events; type can be:
# BEGIN, END, FAIL, REQUEUE or ALL
#SBATCH --job-name=<name> # name of the job
# Note: job arrays should be named
#SBATCH -J <name>
# Actual job script to run
./myexec < input > output
System variables
Note: Do not assign to (only read from) any of these variables inside the SLURM script
SLURM_SUBMIT_DIR # directory from which job was submitted
SLURM_JOB_NODELIST # list of nodes
SLURM_JOB_ID # job ID
SLURM_NTASKS # number of tasks
SLURM_NTASKS_PER_NODE # number of tasks per node
SLURM_CPUS_PER_TASK # number of cores per task
SLURM_ARRAY_JOB_ID # represented by %A in the SLURM script
SLURM_ARRAY_TASK_ID # represented by %a in the SLURM script