Slurm resources
Last updated on 2026-10-27 | Edit this page
Overview
Questions
- What does a job of 4 MPI ranks and 8 threads per rank ask for?
- What do
SLURM_NTASKSandSLURM_CPUS_PER_TASKprint?
Objectives
- Write
--nodes,--ntasks, and--cpus-per-taskfor 4 ranks and 8 threads each. - Check
SLURM_NTASKSandSLURM_CPUS_PER_TASK, then runseff JOBID. - State what
--exclusive,--sockets-per-node, and--gpus-per-noderequest.
Nodes, tasks, and cores
sbatch does not launch tasks. It reserves an allocation
and runs your script. The task options tell Slurm what the later
srun will need.
-
--nodes(or-N) is how many nodes. -
--ntasks(or-n) is the maximum number of tasks the steps in that allocation will launch. Slurm reserves enough resources for that many. -
--ntasks-per-nodeasks for that many tasks on each node. -
--cpus-per-task(or-c) is how many processors each task needs. Without it, Slurm tries to give one processor per task.
Threads are not a separate Slurm option. Eight OpenMP threads on a
rank need --cpus-per-task=8, and the program should set
OMP_NUM_THREADS from SLURM_CPUS_PER_TASK.
The smallest allocation and the partition are in the tabs. The published meaning of the three options above does not change. Whether one node can hold the total does.
Sockets, GPUs, and the shape of the allocation
-
--sockets-per-nodekeeps the selection to nodes that have at least that many sockets. -
--gpus-per-nodeis how many GPUs the job needs on each node. -
--contiguousasks for nodes that form a contiguous set. -
--exclusivemeans the allocation cannot share its nodes with other running jobs.
What the job records
-
SLURM_JOB_NODELISTis the list of nodes allocated to the job. -
SLURM_NTASKSis the value of--ntaskswhen you set it. If you set--ntasks-per-nodeor--ntasks-per-gpuinstead, it is the number of tasks in the job. -
SLURM_CPUS_PER_TASKis the cores requested per task. It is set when you pass--cpus-per-task. -
SLURM_GPUSis the number of GPUs requested. It is set only when you pass-Gor--gpus.
Four ranks, eight threads
A program runs 4 MPI ranks with 8 threads each. Write
--nodes, --ntasks, and
--cpus-per-task. Submit a script that prints the two
variables, then run seff on the job id.
BASH
#!/bin/bash
#SBATCH --job-name=four-eight
#SBATCH --time=00:10:00
#SBATCH --output=four-eight-%j.out
echo "SLURM_NTASKS=$SLURM_NTASKS"
echo "SLURM_CPUS_PER_TASK=$SLURM_CPUS_PER_TASK"
Add your three resource lines, and the partition line from the partition tab. What should the file contain?
The program is 4 ranks and 8 cores per rank:
4 * 8 = 32 cores. --nodes=1 is right when
one node can hold 32 cores. You do not have to set
--ntasks-per-node as well: one node and four tasks already
places four tasks on that node.
SLURM_NTASKS prints 4. SLURM_CPUS_PER_TASK
prints 8 when --cpus-per-task=8 is set. Omit that option
and Slurm tries to allocate one core per task.
If the cpu-minimum tab shows a node smaller than 32 cores, that node cannot take this request unchanged. The tab is where that limit is written. Do not invent a second core count in the script.
seff reports CPU time used, divided by allocated cores
times elapsed time. This script only prints two lines, so the figure
covers a tiny amount of work. Read it as a check that the allocation was
32 cores (4 * 8).
Billing units
A 16-core job’s system billing units are on the accounting tab. That tab already has the arithmetic.
- 4 MPI ranks and 8 threads each is
--ntasks=4and--cpus-per-task=8.--nodes=1when the node can hold 32 cores. -
SLURM_NTASKSis 4 andSLURM_CPUS_PER_TASKis 8 when those options are set. - Without
--cpus-per-task, Slurm tries to allocate one processor per task. -
--exclusivedoes not share nodes.--sockets-per-nodeand--gpus-per-nodeconstrain sockets and GPUs.--contiguousasks for a contiguous set of nodes. -
seff JOBIDis CPU time used, divided by allocated cores times elapsed time. Billing units are the accounting tab.