Slurm refers to processes as “tasks.” A task may be envisioned as an independent, running process. Slurm also refers to cores as “cpus” even though modern cpus contain several to many cores. If your program uses only one core it is a single, sequential task. If it can use multiple cores on the same node, it is generally regarded as a single task, with multiple cores assigned to that task. If it is a distributed code that can run on multiple nodes, each process would be a task.
Options
Note that most Slurm options have two forms, a short (single-letter) form that is preceded by a single hyphen and followed by a space, and a longer form preceded by a double hyphen and followed by an equals sign. In a job script these options are preceded by a pseudocomment #SBATCH. They may also be used as command-line options on their own.
| Option | Usage |
|---|---|
| Number of nodes | -N <n> or --nodes=<n> |
| Number of tasks | -n <n> or --ntasks=<n> |
| Number of processes (tasks) per node | --ntasks-per-node=<n> |
| Total memory per node in megabytes | --mem=<M> |
| Memory per core in megabytes | --mem-per-cpu=<M> |
| Wallclock time | -t d-hh:mm:ss or --time=d-hh:mm:ss |
| Partition (queue) requested | -p <part> or --partition <part> |
| Account to be charged | -A <account> or --account=<allocation> |
Environment variables
These are the most basic; there are many more. By default Slurm changes to the directory from which the job was submitted, so the SLURM_SUBMIT_DIR environment variable is usually not needed.
SLURM_JOB_ID
SLURM_SUBMIT_DIR
SLURM_JOB_PARTITION
SLURM_JOB_NODELIST
Slurm passes all environment variables from the shell in which the sbatch or salloc (or ijob) command was run. To override this behavior in an sbatch script, add
#SBATCH --export=NONE
To export specific variables use
#SBATCH --export=var1,var2,var3
Optionally export and set with
#SBATCH --export=variable1=value1,variable2=value2
Standard Output and Standard Error
By default, Slurm combines standard output and standard error into a single file, which will be named slurm-<jobid>.out. You may rename standard output with
#SBATCH -o <outfile> or --output=<outfile>
To separate standard error from standard output, you must rename both.
#SBATCH -e <errfile> or --error=<errfile>