In remote direct memory access (RDMA) exclusive mode, each pod has exclusive use of the physical RDMA NICs allocated to it. This mode also supports NUMA topology-aware scheduling. Use exclusive mode for workloads that require strict device isolation.
Prerequisites
An ACK managed Pro cluster is created and Lingjun nodes are added. For more information, see Create and manage a Lingjun node pool.
The RDMA device plugin add-on v1.1.5 or later is installed. For more information, see RDMA.
Limits
Some versions of the nvidia-device-plugin add-on are not compatible with exclusive mode:
The community edition of
nvidia-device-pluginv0.19.0 to v0.19.2 enablesMOFED_ENABLEDby default and configures theNVIDIA_MOFEDenvironment variable. This variable causesnvidia-container-toolkitto inject/dev/infinibanddevices into all GPU pods, which conflicts with RDMA exclusive mode and prevents NIC isolation.ack-nvidia-device-pluginv0.7.0 is based on community edition v0.19.1 and has the same issue.
Before you use exclusive mode, upgrade ack-nvidia-device-plugin to v0.8.0 and do not manually set the NVIDIA_MOFED=true environment variable.
Step 1: Enable exclusive mode
Add the node label to the node pool
Log on to the ACK console. In the left navigation pane, click Clusters.
On the Clusters page, click the name of your cluster. In the left navigation pane, choose Nodes > Node Pools.
Find the node pool that contains your Lingjun nodes and edit the node pool configuration. Add a node label whose key is
rdma.network.alibabacloud.com/exclusiveand whose value istrue, and then select Update Labels and Taints of Existing Nodes.
After you save the configuration, the label is automatically added to the nodes in the node pool.
Reload the label on an existing node
For an existing node, manually restart the RDMA device plugin pod so that it reloads the label:
kubectl delete pod -n kube-system -l app=ack-rdma-device-plugin --field-selector spec.nodeName=<node-name>Verify exclusive mode
Check the RDMA resource count on the node. In exclusive mode, the node reports the actual number of devices instead of 1,000, which is the value reported in shared mode:
kubectl describe node <node-name> | grep rdma/hcaThe following output is returned for a node that has four RDMA NICs:
rdma/hca: 4View the RDMA device plugin logs to confirm that the node has entered exclusive mode:
kubectl logs -n kube-system -l app=ack-rdma-device-plugin --tail=20The following output is returned:
node <node-name> has exclusive label, enabling exclusive mode
hca-exclusive mode
discovered RDMA device: mlx5_bond_0 (PCI=0000:7f:00.0, NUMA=0, uverbs=uverbs0, pcieRoot=pci0000:7b)
discovered RDMA device: mlx5_bond_1 (PCI=0000:c7:00.0, NUMA=0, uverbs=uverbs1, pcieRoot=pci0000:c3)
discovered RDMA device: mlx5_bond_2 (PCI=0001:08:00.0, NUMA=1, uverbs=uverbs2, pcieRoot=pci0001:05)
discovered RDMA device: mlx5_bond_3 (PCI=0001:a2:00.0, NUMA=1, uverbs=uverbs3, pcieRoot=pci0001:9f)
Registered device plugin with KubeletStep 2: Configure NUMA topology-aware scheduling (optional)
In exclusive mode, the RDMA device plugin carries NUMA node information when it registers devices. Based on this information, the kubelet Topology Manager performs NUMA topology-aware scheduling for CPUs and RDMA devices.
To use NUMA topology-aware scheduling, set cpuManagerPolicy and topologyManagerPolicy in the custom kubelet parameters of the node pool. The following table describes the two parameters.
Parameter | Valid values | Description |
|
| Specifies the CPU management policy. The |
|
| Specifies how resources are aligned across NUMA nodes. |
(Recommended) Set cpuManagerPolicy to static and topologyManagerPolicy to best-effort. This combination aligns resources with NUMA nodes on a best-effort basis without preventing pods from being scheduled, so that GPU and RDMA resources are allocated within the same NUMA node. For more information about the parameters, see Customize node pool kubelet configurations.
Step 3: Use RDMA resources
Exclusive mode uses the same YAML format as shared mode to request rdma/hca resources. From the available RDMA devices, kubelet allocates the specified number of physical NICs to the pod.
Create a Job that requests rdma/hca resources. Replace <image> with an image that provides your test script at /workspace/benchmark.py.
apiVersion: batch/v1
kind: Job
metadata:
name: rdma-exclusive-test
spec:
parallelism: 1
template:
spec:
tolerations:
- operator: Exists
containers:
- name: rdma-test
image: "<image>"
command:
- sh
- -c
- |
python /workspace/benchmark.py
resources:
limits:
nvidia.com/gpu: 8
rdma/hca: 2
workingDir: /root
volumeMounts:
- name: shm
mountPath: /dev/shm
securityContext:
capabilities:
add:
- SYS_RESOURCE
- IPC_LOCK
restartPolicy: Never
volumes:
- name: shm
emptyDir:
medium: Memory
sizeLimit: 8GiThe following table describes the key configuration items in the preceding template.
Configuration item | Description |
| Requests two exclusive RDMA devices. kubelet allocates two physical RDMA NICs to the pod. |
| Requests GPU resources. Adjust the value based on your requirements. |
| Mounts a shared memory volume that multiple processes use to share data. |
| Adds the Linux capabilities that RDMA applications require. |
Switch back to shared mode
Before you switch modes, make sure that no pod on the node uses rdma/hca resources. Otherwise, the switch invalidates the device allocations of the existing pods.
Remove the
rdma.network.alibabacloud.com/exclusivelabel from the node pool configuration.Restart the device plugin pod:
kubectl delete pod -n kube-system -l app=ack-rdma-device-plugin --field-selector spec.nodeName=<node-name>
After the restart, the rdma/hca resource count returns to 1,000, which indicates that the node is back in shared mode.
References
To use shared mode, see Use RDMA shared mode.