Skip to main content
Using task plugins, you can set Slurm parameters to bind a task to specific subsets of resources on a node, like CPU cores or GPUs. You can optimize the performance of a task in Slurm by selecting resources within a common Non-Uniform Memory Access (NUMA) node. Resources can access memory within their own NUMA node much more quickly than memory in a separate NUMA node, which can reduce data transfer latency and improve job performance. This guide explains how to manage resource binding in SUNK with task plugins. It’s intended for cluster administrators who configure Slurm and for users who submit jobs that benefit from CPU or GPU affinity. The following sections describe how to enable resource binding, configure the task cgroup plugin, and bind tasks to GPUs and CPU cores.

Enable resource binding

To enable resource binding, modify the TaskPlugin 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:
This enables the 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

cgroup v1 is deprecated in Slurm 25.05 and laterSUNK v7.0.0 upgrades to Slurm 25.05, where the cgroup v1 plugin is deprecated. Slurm does not add new cgroup v1 features and plans to remove cgroup v1 support in a future release. For details, see Control Group in Slurm in the SchedMD documentation.Set CgroupPlugin to cgroup/v2 slurmConfig.cgroupConfig as shown in the following example. CKS clusters on Kubernetes v1.35 and later require cgroup v2 on all nodes. See Cluster components for cgroup version requirements by Kubernetes version.
With resource binding enabled, the next step is to configure how Slurm enforces those bindings. SUNK supports Linux cgroups through the cgroup.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:
  1. Add the task/cgroup value to the TaskPlugin variable, as shown in the Enable resource binding section.
  2. In the slurmConfig section of the Slurm values.yaml, set the procTrackType variable to proctrack/cgroup. If you don’t set this parameter correctly, Slurm doesn’t apply your Linux cgroups settings.
This enables cgroups with the following settings:
The Constrain settings enforce binding and limits for different resources, as follows:
  • ConstrainCores=yes enforces CPU binding.
  • ConstrainDevices=yes enforces limits on GPU devices.
  • ConstrainRAMSpace=yes enforces 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:
To print information about which GPU resources each task binds to, add the verbose option to your other binding options, separated by a comma. This can be helpful when debugging or checking your binding strategy.
Performance optimizationTo optimize performance, use the --gpu-bind=single:1 option when starting your Slurm job. This binds each task to one GPU, chosen from the GPUs whose socket affinity matches the task’s allocated CPU cores. Matching CPU and GPU NUMA affinities is important for performance. If you don’t use the --gpu-bind parameter, Slurm could assign your task a GPU with a different NUMA affinity than the assigned CPU cores, which could lead to suboptimal performance. GPU binding doesn’t change how Slurm spreads a job’s CPU cores across NUMA nodes. For that, see Align tasks with NUMA nodes for multi-GPU jobs.
The --gpu-bind parameter supports multiple options, including: For a complete list of available --gpu-bind options, see SchedMD’s Slurm documentation.

Run two jobs on one GPU node

Slurm can run multiple jobs on the same node when each job requests only the resources it needs. This example submits two jobs to one node with at least two available GPUs. Each job requests one GPU, one CPU, and 1 GB of memory. The node’s remaining resources stay available to other jobs. To submit the jobs, complete these steps:
  1. Create a job script named gpu-share.sh:
  2. Submit the script twice to the same node. Replace [NODE-NAME] with the name of a node that has at least two available GPUs:
After both jobs start, squeue shows that both jobs run on the same node. Slurm’s gres/gpu allocation sets SLURM_JOB_GPUS in each job’s environment to the physical GPU it holds. The job output files, gpu-share-${job_one}.out and gpu-share-${job_two}.out, show a different SLURM_JOB_GPUS value for each job, confirming that Slurm assigned them separate GPUs. CUDA_VISIBLE_DEVICES isn’t a reliable way to tell the jobs apart. With ConstrainDevices=yes, Linux cgroups restrict each job to only its allocated GPU device file, and Slurm remaps CUDA_VISIBLE_DEVICES to a job-local index that starts at 0. Because each job in this example holds a single GPU, both output files show CUDA_VISIBLE_DEVICES=0, even though the jobs run on different physical GPUs. Without ConstrainDevices=yes, a job can access every GPU on the node instead of only the one it was assigned, so CUDA_VISIBLE_DEVICES reports the real GPU index but doesn’t restrict access to it. Either way, use SLURM_JOB_GPUS or scontrol show job -d [JOB-ID] to find a job’s actual physical GPU.

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:
To print information about which CPU resources each task binds to, add the 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.

Align tasks with NUMA nodes for multi-GPU jobs

CPU binding controls which cores a task uses, but it doesn’t by itself fix how Slurm spreads ranks across NUMA nodes. By default, Slurm distributes tasks cyclically (round-robin across sockets), which can place a task’s CPU cores on a different NUMA node than its GPU. On multi-GPU nodes, this NUMA misalignment can cause a substantial slowdown on chip-to-chip (C2C) heavy workloads. To align ranks with NUMA nodes, add block distribution to your job:
This allocates cores contiguously so consecutive ranks land on the same NUMA node as their GPU. For per-instance NUMA topology tables, verification commands, and how administrators make block distribution the cluster-wide default, see Optimize CPU binding and NUMA affinity for multi-GPU jobs.
Last modified on September 18, 2026