Enable Hygon HCU sharing
The community dcu-vgpu-device-plugin repository is archived and will no longer be updated. HCU users should use the latest versions of HAMi and the k8s-hcu-device-plugin provided by Hygon.
The vendor-driven rename from DCU to HCU is a breaking change: the old DCU resource names are no longer supported by default. HAMi follows the vendor's new naming; this incompatibility results from the rename rather than a HAMi scheduling defect. If your device plugin still uses DCU names, set devices.hygon.resourcePrefix: dcu when you upgrade (see Resource prefix).
Introduction
HAMi supports sharing Hygon HCU devices with most of the device-sharing features available for NVIDIA GPUs, including:
HCU sharing: Each task can allocate a portion of HCU instead of a whole HCU card, thus HCU can be shared among multiple tasks.
Device Memory Control: HCUs can be allocated with a specific device memory size on certain types (e.g., Z100), with hard limits enforced to prevent exceeding the allocation.
Device compute core limitation: HCUs can be allocated with certain percentage of device core (i.e., hygon.com/hcucores:60 indicates this container uses 60% compute cores of this device)
HCU Type Specification: You can specify which type of HCU to use or to avoid for a certain task, by setting "hygon.com/use-hcutype" or "hygon.com/nouse-hcutype" annotations.
Prerequisites
- dtk driver >= 24.04
- hy-smi v1.6.0
Enabling HCU-sharing Support
Install HAMi using Online installation. The vendor device plugin is installed separately as described below. HAMi-side resource names and device settings are under devices.hygon.* in the Chart values reference; keep resource names consistent with the plugin.
- Deploy the k8s-hcu-device-plugin provided by Hygon. Follow the deployment instructions in its README.
Resource prefix
By default, HAMi uses the hcu prefix, so workloads request hygon.com/hcunum, hygon.com/hcumem, and hygon.com/hcucores. New clusters can leave this unchanged.
If you are upgrading a cluster whose device plugin still reports DCU names, set the same prefix on HAMi:
devices:
hygon:
resourcePrefix: dcu
That switches the resource names to hygon.com/dcunum, hygon.com/dcumem, and hygon.com/dcucores, and the type-selection annotations to hygon.com/use-dcutype and hygon.com/nouse-dcutype. HAMi and the device plugin must use the same prefix, or Pods will not schedule.
If you supply the full device configuration yourself with device-config.content or files/device-config.yaml, devices.hygon.resourcePrefix above does not apply. Put the prefix or resource names in that file instead. See Device ConfigMap generation and updates.
Running HCU jobs
Hygon HCUs can now be requested by a container using the hygon.com/hcunum, hygon.com/hcumem and hygon.com/hcucores resource type:
apiVersion: v1
kind: Pod
metadata:
name: alexnet-tf-gpu-pod-mem
labels:
purpose: demo-tf-amdgpu
spec:
containers:
- name: alexnet-tf-gpu-container
image: harbor.sourcefind.cn:5443/hcu/admin/base/pytorch:2.1.0-ubuntu22.04-dtk24.04.2-py3.10
workingDir: /root
command: ["sleep", "infinity"]
resources:
limits:
hygon.com/hcunum: 1 # requesting an HCU
hygon.com/hcumem: 2000 # each hcu require 2000 MiB device memory
hygon.com/hcucores: 60 # each hcu use 60% of total compute cores
Enable vHCU inside container
You need to enable vHCU inside the container to use it.
source /opt/hygondriver/env.sh
Check if you have successfully enabled vHCU by using the following command:
hy-smi virtual -show-device-info
If you have an output like this, then you have successfully enabled vHCU inside container.
Device 0:
Actual Device: 0
Compute units: 60
Global memory: 2097152000 bytes
Launch your HCU tasks like you usually do
Notes
-
HCU-sharing in init container is not supported, pods with "hygon.com/hcumem" in init container will never be scheduled.
-
Only one vhcu can be acquired per container. If you want to mount multiple hcu devices, then you should not set
hygon.com/hcumemorhygon.com/hcucores