Enable resource binding
To enable resource binding, modify theTaskPlugin variable in the Slurm configuration section of the SUNK Helm chart.
In the slurmConfig section of the Slurm values.yaml file, set the TaskPlugin variable to task/affinity,task/cgroup:
task/affinity and task/cgroup plugins, which work together to optimize resource allocations in the SUNK cluster. The task/affinity plugin controls how processes bind to CPU resources on a Compute node. The task/cgroup plugin uses the cgroup filesystem and its controllers to enforce the resource limits and binding policies specified by Slurm.
Configure the task cgroup plugin
With resource binding enabled, the next step is to configure how Slurm enforces those bindings. SUNK supports Linux cgroups through thecgroup.conf value, slurmConfig.cgroupConfig, which uses kernel cgroups to enforce CPU, GPU, and memory constraints on each task.
To use Linux cgroups in SUNK, do the following:
- Add the
task/cgroupvalue to theTaskPluginvariable, as shown in the Enable resource binding section. - In the
slurmConfigsection of the Slurmvalues.yaml, set theprocTrackTypevariable toproctrack/cgroup. If you don’t set this parameter correctly, Slurm doesn’t apply your Linux cgroups settings.
Constrain settings enforce binding and limits for different resources, as follows:
ConstrainCores=yesenforces CPU binding.ConstrainDevices=yesenforces limits on GPU devices.ConstrainRAMSpace=yesenforces memory limits.
Bind tasks to GPUs
Once the task plugins and cgroup configuration are in place, you can control how Slurm assigns individual jobs to GPUs. Use the--gpu-bind parameter in your job script’s #SBATCH directives to manage how Slurm assigns tasks to GPUs:
verbose option to your other binding options, separated by a comma. This can be helpful when debugging or checking your binding strategy.
The --gpu-bind parameter supports multiple options, including:
For a complete list of available
--gpu-bind options, see SchedMD’s Slurm documentation.
Bind tasks to CPU cores
In addition to GPU binding, you can pin tasks to specific CPU cores to improve cache locality and reduce contention. Use the--cpu-bind parameter in your job script’s #SBATCH directives to control which CPU cores your tasks bind to. For example:
verbose option to your other binding options, separated by a comma. This can be helpful when debugging or checking your binding strategy.
The --cpu-bind parameter supports multiple options, including:
For a full list of available
--cpu-bind options, see SchedMD’s Slurm documentation.