Constraints¶
Constraints (also known as features) provide a way to make more specific resource requests within a group of nodes. They allow you to target nodes with specific characteristics, such as a certain node type, hardware configuration, or GPU architecture (GPU nodes only), so workloads are scheduled only on nodes that meet those requirements.
Since using constraints gives a more granular way to request resources, it can reduce the number of nodes available to run your job. As a result, constraints should be used only for specific use cases and not for generic jobs.
For more information, see the official Slurm documentation.
Available constraints¶
To view a list of constraints applied to all nodes within each partition:
sinfo --Format=partition,features
Requesting constraints¶
There are two ways to request node features in Slurm:
--constraint: enforces a strict requirement; the job runs only on nodes that match the specified feature.--prefer: sets a soft preference; the job prefers nodes with the feature but can run on others if needed.
Both options can accept a single feature or multiple features. Continue reading for examples showing different ways to combine constraints.
See the
official Slurm documentation
for more information about the --prefer option.
Single constraint¶
To request a single feature/constraint, add the following to your job script:
#SBATCH --constraint=<feature_name>
where <feature_name> is a valid constraint.
Multiple constraints¶
To request multiple constraints, combine them with logical operators. The two main ways are:
AND (&): the node must meet all listed features.OR (|): the node can have any one of the features.
The below shows an example for each logical operator:
# Request both the 'hopper' AND 'h100' constraints
sbatch --constraint="hopper&h100"
# Request either the 'ampere' OR 'hopper' constraint
sbatch --constraint="ampere|hopper"