Skip to content

Latest commit

 

History

History
144 lines (102 loc) · 3.83 KB

File metadata and controls

144 lines (102 loc) · 3.83 KB

Ascend Device Plugin

说明

Ascend device plugin 是用来支持在 HAMivolcano 中调度昇腾NPU设备.

基于模板的硬切分 (vNPU)

支持基于虚拟化模板的显存切分,系统会自动使用最小可用模板。详细信息请参阅 template

基于运行时拦截的软切分 (hami-vnpu-core)

实现了基于 libvnpu.so 拦截和limiter令牌调度的软切分机制,能够实现精细化的资源共享。详细信息请参阅 hami-vnpu-core

注意: hami-vnpu-core目前只支持ARM平台。

环境要求

部署 ascend-docker-runtime

更新子模块

git submodule update --init --recursive

hami-vnpu-core 软切分要求:

  • Ascend 驱动版本:≥ 25.5
  • 芯片模式:在昇腾芯片上开启 device-share 模式以支持虚拟化。

编译

make all

编译镜像

docker buildx build -t $IMAGE_NAME .

部署

给 Node 打 ascend 标签

kubectl label node {ascend-node} ascend=on

部署 ConfigMap

kubectl apply -f ascend-device-configmap.yaml

部署 RuntimeClass

kubectl apply -f ascend-runtimeclass.yaml

部署 ascend-device-plugin

kubectl 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。

在 HAMi 中使用

...
    containers:
    - name: npu_pod
      ...
      resources:
        limits:
          huawei.com/Ascend910B: "1"
          # 如果不指定显存大小, 就会使用整张卡
          huawei.com/Ascend910B-memory: "4096"

For more examples, see examples

软切分配置 (HAMi)

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 中使用时需要提前部署好 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"