NVIDIA Data Center GPU Manager(DCGM)

このドキュメントでは、Google Cloud Managed Service for Prometheus を使用して NVIDIA データセンター GPU マネージャーから指標を収集できるように、Google Kubernetes Engine の Deployment を構成する方法について説明します。このドキュメントでは、次の方法について説明します。

  • DCGM のエクスポータを設定して、指標を報告する。
  • エクスポートされた指標を収集するために、Managed Service for Prometheus の PodMonitoring リソースを構成する。

以下の手順は、Managed Service for Prometheus でマネージド コレクションを使用している場合にのみ適用されます。セルフデプロイ コレクションを使用している場合は、DCGM Exporter のソース リポジトリでインストール情報をご覧ください。

以下の手順は一例であり、ほとんどの Kubernetes 環境で機能します。セキュリティ ポリシーや組織のポリシーの制限により、アプリケーションやエクスポータのインストールに問題がある場合は、オープンソース ドキュメントでサポートを確認することをおすすめします。

DCGM の詳細については、NVIDIA DCGM をご覧ください。

前提条件

Managed Service for Prometheus とマネージド コレクションを使用して DCGM から指標を収集するには、Deployment が次の要件を満たしている必要があります。

  • クラスタで Google Kubernetes Engine バージョン 1.21.4-gke.300 以降を実行している必要があります。
  • マネージド コレクションを有効にして、Managed Service for Prometheus を実行する必要があります。詳細については、マネージド コレクションを使ってみるをご覧ください。

  • NVIDIA GPU に十分な割り当てがあることを確認します。

  • GKE クラスタ内の GPU ノードと、関連するクラスタ内の GPU ノードを列挙するには、次のコマンドを実行します。

    kubectl get nodes -l cloud.google.com/gke-gpu -o jsonpath='{range .items[*]}{@.metadata.name}{" "}{@.metadata.labels.cloud\.google\.com/gke-accelerator}{"\n"}{end}'
    
  • 自動インストールが無効になっている場合、または GKE バージョンでサポートされていない場合は、ノードに互換性のある NVIDIA GPU ドライバをインストールする必要がある場合があります。NVIDIA GPU デバイス プラグインが実行されていることを確認するには、次のコマンドを実行します。

    kubectl get pods -n kube-system | grep nvidia-gpu-device-plugin
    

DCGM エクスポータをインストールする

次の構成を使用して、DCGM エクスポータである DCGM-Exporter をインストールすることをおすすめします。

# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nvidia-dcgm
  namespace: gmp-public
  labels:
    app: nvidia-dcgm
spec:
  selector:
    matchLabels:
      app: nvidia-dcgm
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        name: nvidia-dcgm
        app: nvidia-dcgm
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: cloud.google.com/gke-accelerator
                operator: Exists
      tolerations:
      - operator: "Exists"
      volumes:
      - name: nvidia-install-dir-host
        hostPath:
          path: /home/kubernetes/bin/nvidia
      containers:
      - image: "nvcr.io/nvidia/cloud-native/dcgm:3.3.0-1-ubuntu22.04"
        command: ["nv-hostengine", "-n", "-b", "ALL"]
        ports:
        - containerPort: 5555
          hostPort: 5555
        name: nvidia-dcgm
        securityContext:
          privileged: true
        volumeMounts:
        - name: nvidia-install-dir-host
          mountPath: /usr/local/nvidia
---
apiVersion: apps/v1
kind: DaemonSet
metadata:
  name: nvidia-dcgm-exporter
  namespace: gmp-public
  labels:
    app.kubernetes.io/name: nvidia-dcgm-exporter
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: nvidia-dcgm-exporter
  updateStrategy:
    type: RollingUpdate
  template:
    metadata:
      labels:
        app.kubernetes.io/name: nvidia-dcgm-exporter
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: cloud.google.com/gke-accelerator
                operator: Exists
      tolerations:
      - operator: "Exists"
      volumes:
      - name: nvidia-dcgm-exporter-metrics
        configMap:
          name: nvidia-dcgm-exporter-metrics
      - name: nvidia-install-dir-host
        hostPath:
          path: /home/kubernetes/bin/nvidia
      - name: pod-resources
        hostPath:
          path: /var/lib/kubelet/pod-resources
      containers:
      - name: nvidia-dcgm-exporter
        image: nvcr.io/nvidia/k8s/dcgm-exporter:3.3.0-3.2.0-ubuntu22.04
        command: ["/bin/bash", "-c"]
        args:
        - hostname $NODE_NAME; dcgm-exporter --remote-hostengine-info $(NODE_IP) --collectors /etc/dcgm-exporter/counters.csv
        ports:
        - name: metrics
          containerPort: 9400
        securityContext:
          privileged: true
        env:
        - name: NODE_NAME
          valueFrom:
            fieldRef:
              fieldPath: spec.nodeName
        - name: "DCGM_EXPORTER_KUBERNETES_GPU_ID_TYPE"
          value: "device-name"
        - name: LD_LIBRARY_PATH
          value: /usr/local/nvidia/lib64
        - name: NODE_IP
          valueFrom:
            fieldRef:
              fieldPath: status.hostIP
        - name: DCGM_EXPORTER_KUBERNETES
          value: 'true'
        - name: DCGM_EXPORTER_LISTEN
          value: ':9400'
        volumeMounts:
        - name: nvidia-dcgm-exporter-metrics
          mountPath: "/etc/dcgm-exporter"
          readOnly: true
        - name: nvidia-install-dir-host
          mountPath: /usr/local/nvidia
        - name: pod-resources
          mountPath: /var/lib/kubelet/pod-resources
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: nvidia-dcgm-exporter-metrics
  namespace: gmp-public
data:
  counters.csv: |
    # Utilization (the sample period varies depending on the product),,
    DCGM_FI_DEV_GPU_UTIL, gauge, GPU utilization (in %).
    DCGM_FI_DEV_MEM_COPY_UTIL, gauge, Memory utilization (in %).

    # Temperature and power usage,,
    DCGM_FI_DEV_GPU_TEMP, gauge, Current temperature readings for the device in degrees C.
    DCGM_FI_DEV_MEMORY_TEMP, gauge, Memory temperature for the device.
    DCGM_FI_DEV_POWER_USAGE, gauge, Power usage for the device in Watts.

    # Utilization of IP blocks,,
    DCGM_FI_PROF_SM_ACTIVE, gauge, The ratio of cycles an SM has at least 1 warp assigned
    DCGM_FI_PROF_SM_OCCUPANCY, gauge, The fraction of resident warps on a multiprocessor
    DCGM_FI_PROF_PIPE_TENSOR_ACTIVE, gauge, The ratio of cycles the tensor (HMMA) pipe is active (off the peak sustained elapsed cycles)
    DCGM_FI_PROF_PIPE_FP64_ACTIVE, gauge, The fraction of cycles the FP64 (double precision) pipe was active.
    DCGM_FI_PROF_PIPE_FP32_ACTIVE, gauge, The fraction of cycles the FP32 (single precision) pipe was active.
    DCGM_FI_PROF_PIPE_FP16_ACTIVE, gauge, The fraction of cycles the FP16 (half precision) pipe was active.

    # Memory usage,,
    DCGM_FI_DEV_FB_FREE, gauge, Framebuffer memory free (in MiB).
    DCGM_FI_DEV_FB_USED, gauge, Framebuffer memory used (in MiB).
    DCGM_FI_DEV_FB_TOTAL, gauge, Total Frame Buffer of the GPU in MB.

    # PCIE,,
    DCGM_FI_PROF_PCIE_TX_BYTES, gauge, Total number of bytes transmitted through PCIe TX
    DCGM_FI_PROF_PCIE_RX_BYTES, gauge, Total number of bytes received through PCIe RX

    # NVLink,,
    DCGM_FI_PROF_NVLINK_TX_BYTES, gauge, The number of bytes of active NvLink tx (transmit) data including both header and payload.
    DCGM_FI_PROF_NVLINK_RX_BYTES, gauge, The number of bytes of active NvLink rx (read) data including both header and payload.
予想されるエンドポイントで DCGM エクスポータが指標を出力していることを確認するには、次の操作を行います。

  1. 次のコマンドを使用してポート転送を設定します。

    kubectl -n gmp-public port-forward POD_NAME 9400
    
  2. 別のターミナル セッションでブラウザまたは curl ユーティリティを使用して、localhost:9400/metrics エンドポイントにアクセスします。

ConfigMap セクションをカスタマイズして、出力する GPU 指標を選択できます。

または、公式 Helm チャートを使用して DCGM エクスポータをインストールすることを検討してください。

構成の変更をローカル ファイルから適用するには、次のコマンドを実行します。

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

Terraform を使用して構成を管理することもできます。

PodMonitoring リソースを定義する

ターゲット ディスカバリの場合、Managed Service for Prometheus Operator には、同じ Namespace 内の DCGM エクスポータに対応する PodMonitoring リソースが必要です。

次の PodMonitoring 構成を使用できます。

# Copyright 2023 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     https://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: monitoring.googleapis.com/v1
kind: PodMonitoring
metadata:
  name: nvidia-dcgm-exporter
  namespace: gmp-public
  labels:
    app.kubernetes.io/name: nvidia-dcgm-exporter
    app.kubernetes.io/part-of: google-cloud-managed-prometheus
spec:
  selector:
    matchLabels:
      app.kubernetes.io/name: nvidia-dcgm-exporter
  endpoints:
  - port: metrics
    interval: 30s

構成の変更をローカル ファイルから適用するには、次のコマンドを実行します。

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

Terraform を使用して構成を管理することもできます。

構成を確認する

Metrics Explorer を使用すると、DCGM エクスポータが正しく構成されていることを確認できます。Cloud Monitoring が指標を取り込むまでに 1~2 分かかる場合があります。

指標が取り込まれていることを確認します。

  1. Google Cloud コンソールのナビゲーション パネルで [Monitoring] を選択し、次に [ Metrics Explorer] を選択します。

    Metrics Explorer に移動

  2. クエリビルダー ペインのツールバーで、[MQL] または [PROMQL] という名前のボタンを選択します。
  3. [言語] で [PromQL] が選択されていることを確認します。言語切り替えボタンは、クエリの書式設定と同じツールバーにあります。
  4. 次のクエリを入力して実行します。
    DCGM_FI_DEV_GPU_UTIL{cluster="CLUSTER_NAME", namespace="gmp-public"}
    

トラブルシューティング

指標の取り込みに関する問題のトラブルシューティングについては、取り込み側の問題のトラブルシューティングエクスポータからの収集に関する問題をご覧ください。