使用 CLI 创建 Hardware Profile

本文档介绍如何使用命令行创建 HardwareProfile 资源,并提供一个示例 YAML。

前提条件

  • 你可以访问已安装该平台的 Kubernetes 集群。
  • 你已配置 kubectl 可与集群通信。
  • 你在管理 HardwareProfile 资源的命名空间中拥有权限(例如,像 kube-public 这样的管理员命名空间)。

创建 HardwareProfile

创建一个名为 gpu-high-performance-profile.yaml 的 YAML 文件,内容如下:

apiVersion: infrastructure.opendatahub.io/v1alpha1
kind: HardwareProfile
metadata:
  name: gpu-high-performance-profile
  namespace: kube-public
spec:
  # Define resource limitations and defaults
  identifiers:
    - identifier: "nvidia.com/gpu"
      displayName: "GPU"
      minCount: "1"
      maxCount: "8"
      defaultCount: "1"
      resourceType: Accelerator
    - identifier: "cpu"
      displayName: "CPU"
      minCount: "4"
      maxCount: "32"
      defaultCount: "8"
      resourceType: CPU
    - identifier: "memory"
      displayName: "Memory"
      minCount: "16Gi"
      maxCount: "128Gi"
      defaultCount: "32Gi"
      resourceType: Memory
  # Configure Node Selectors and Tolerations for scheduling
  scheduling:
    type: Node
    node:
      nodeSelector:
        accelerator: nvidia-a100
        node-role.kubernetes.io/worker: "true"
      tolerations:
        - key: "nvidia.com/gpu"
          operator: "Exists"
          effect: "NoSchedule"

然后使用 kubectl 将该 YAML 文件应用到集群:

kubectl apply -f gpu-high-performance-profile.yaml -n kube-public

检查 HardwareProfile 状态

你可以使用以下命令检查 HardwareProfile 是否已成功创建:

kubectl get hardwareprofile gpu-high-performance-profile -n kube-public

输出应类似如下:

NAME                           AGE
gpu-high-performance-profile   2m

正确应用后,数据科学家在使用 UI 部署其推理服务时,将能够选择 GPU High Performance,并且配置文件中指定的约束会自动验证并注入到已部署的工作负载中。