Ascend device plugin 是用来支持在 HAMi 和 volcano 中调度昇腾NPU设备.
基于模板的硬切分 (vNPU)
支持基于虚拟化模板的显存切分,系统会自动使用最小可用模板。详细信息请参阅 template。
基于运行时拦截的软切分 (hami-vnpu-core)
实现了基于 libvnpu.so 拦截和limiter令牌调度的软切分机制,能够实现精细化的资源共享。详细信息请参阅 hami-vnpu-core。
注意: hami-vnpu-core目前只支持ARM平台。
更新子模块
git submodule update --init --recursivehami-vnpu-core 软切分要求:
- Ascend 驱动版本:≥ 25.5
- 芯片模式:在昇腾芯片上开启
device-share模式以支持虚拟化。
make alldocker buildx build -t $IMAGE_NAME .kubectl label node {ascend-node} ascend=onkubectl apply -f ascend-device-configmap.yamlkubectl apply -f ascend-runtimeclass.yamlkubectl apply -f ascend-device-plugin.yaml如果要在HAMi中使用升腾NPU, 在部署HAMi时设置 devices.ascend.enabled 为 true 会自动部署 ConfigMap 和 ascend-device-plugin。 参考 https://github.com/Project-HAMi/HAMi/blob/master/charts/hami/README.md#huawei-ascend
如果需要 HAMi 为申请 ascend 资源的 Pod 自动添加 runtimeClassName 配置(默认关闭),则应该在 HAMi 的 values.yaml 文件中配置 deivces.ascend.runtimeClassName 为一个非空字符串,并且与 RuntimeClass 资源名称保持一致。 例如:
devices:
ascend:
runtimeClassName: ascend如果要独占整卡或者申请多张卡只需要设置对应的 resourceName 即可。如果多个任务要共享同一张卡,需要将 resourceName 设置为1,并且设置对应的 ResourceMemoryName。
...
containers:
- name: npu_pod
...
resources:
limits:
huawei.com/Ascend910B: "1"
# 如果不指定显存大小, 就会使用整张卡
huawei.com/Ascend910B-memory: "4096"For more examples, see examples
YAML
apiVersion: v1
kind: Pod
metadata:
name: ascend-soft-slice-pod
annotations:
huawei.com/vnpu-mode: 'hami-core' # 添加该注解的走hami-vnpu-core软切分
spec:
containers:
- name: npu_pod
...
resources:
limits:
huawei.com/Ascend910B3: "1" # 请求 1 块物理 NPU
huawei.com/Ascend910B3-memory: "28672" # 请求 28Gi 显存
huawei.com/Ascend910B3-core: "40" # 请求 40% 的算力在 volcano 中使用时需要提前部署好 volcano, 更多信息请参考这里
apiVersion: v1
kind: Pod
metadata:
name: ascend-pod
spec:
schedulerName: volcano
containers:
- name: ubuntu-container
image: swr.cn-south-1.myhuaweicloud.com/ascendhub/ascend-pytorch:24.0.RC1-A2-1.11.0-ubuntu20.04
command: ["sleep"]
args: ["100000"]
resources:
limits:
huawei.com/Ascend310P: "1"
huawei.com/Ascend310P-memory: "4096"