NVIDIA Data Center GPU Manager (DCGM)

במאמר הזה מוסבר איך להגדיר את פריסת Google Kubernetes Engine כדי שתוכלו להשתמש בשירות המנוהל של Google Cloud ל-Prometheus לאיסוף מדדים מ-NVIDIA Data Center GPU Manager. במאמר הזה מוסבר איך:

  • מגדירים את המייצא של DCGM כדי לדווח על מדדים.

ההוראות האלה רלוונטיות רק אם אתם משתמשים באיסוף מנוהל עם שירות מנוהל ל-Prometheus. אם אתם משתמשים באיסוף בפריסה עצמית, עיינו במאגר המקור של DCGM Exporter כדי לקבל מידע על ההתקנה.

ההוראות האלה הן דוגמה, והן אמורות לפעול ברוב סביבות Kubernetes. למידע על הצעה מנוהלת של DCGM, קראו את המאמר איסוף והצגה של מדדי DCGM.

אם אתם נתקלים בבעיות בהתקנה של אפליקציה או של כלי ייצוא בגלל מדיניות אבטחה או מדיניות ארגונית מגבילה, מומלץ לעיין במסמכי התיעוד של קוד פתוח כדי לקבל תמיכה.

למידע נוסף על NVIDIA Data Center GPU Manager, קראו את המאמר NVIDIA DCGM.

דרישות מוקדמות

כדי לאסוף מדדים מ-DCGM באמצעות השירות המנוהל ל-Prometheus ואיסוף מנוהל, הפריסה צריכה לעמוד בדרישות הבאות:

  • באשכול צריכה לפעול גרסה 1.28.15-gke.2475000 ומעלה של Google Kubernetes Engine.
  • צריך להפעיל את השירות המנוהל ל-Prometheus עם איסוף מנוהל. מידע נוסף זמין במאמר תחילת העבודה עם גבייה מנוהלת.

  • מוודאים שיש לכם מספיק מכסה למעבדי GPU של NVIDIA.

  • כדי למנות את צומתי ה-GPU באשכול GKE ואת סוגי ה-GPU שלהם באשכול הרלוונטי, מריצים את הפקודה הבאה:

    kubectl get nodes -l cloud.google.com/gke-accelerator -o jsonpath='{range .items[*]}{@.metadata.name}{" "}{@.metadata.labels.cloud\.google\.com/gke-accelerator}{"\n"}{end}'
    
  • שימו לב: יכול להיות שתצטרכו להתקין מנהל התקן תואם של NVIDIA GPU בצמתים אם ההתקנה האוטומטית הושבתה או לא נתמכת בגרסת GKE שלכם. כדי לוודא שהפלאגין של NVIDIA GPU פועל, מריצים את הפקודה הבאה:

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

התקנת DCGM exporter

מומלץ להתקין את ה-exporter של 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
          type: Directory
      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
          type: Directory
      - 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 Exporter פולט מדדים בנקודות הקצה הצפויות:

  1. מגדירים העברה ליציאה אחרת באמצעות הפקודה הבאה:

    kubectl -n gmp-public port-forward POD_NAME 9400
    
  2. נכנסים לנקודת הקצה localhost:9400/metrics באמצעות הדפדפן או הכלי curl בסשן אחר של הטרמינל.

אפשר להתאים אישית את הקטע ConfigMap כדי לבחור אילו מדדי GPU להפיק.

לחלופין, אפשר להשתמש בתרשים הרשמי של Helm כדי להתקין את DCGM Exporter.

כדי להחיל שינויים בהגדרות מקובץ מקומי, מריצים את הפקודה הבאה:

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

אפשר גם להשתמש ב-Terraform כדי לנהל את ההגדרות.

הגדרת משאב PodMonitoring

כדי לזהות יעדים, המפעיל של השירות המנוהל ל-Prometheus דורש משאב PodMonitoring שתואם ל-DCGM Exporter באותו מרחב שמות.

אפשר להשתמש בהגדרת 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: ClusterPodMonitoring
metadata:
  name: nvidia-dcgm-exporter
  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
  targetLabels:
    metadata: []

כדי להחיל שינויים בהגדרות מקובץ מקומי, מריצים את הפקודה הבאה:

kubectl apply -n NAMESPACE_NAME -f FILE_NAME

אפשר גם להשתמש ב-Terraform כדי לנהל את ההגדרות.

אימות ההגדרות האישיות

אתם יכולים להשתמש ב-Metrics Explorer כדי לוודא שהגדרתם נכון את DCGM Exporter. יכול להיות שיעברו דקה או שתיים עד ש-Cloud Monitoring יקלוט את המדדים.

כדי לוודא שהמדדים נקלטים, מבצעים את הפעולות הבאות:

  1. במסוף Google Cloud , נכנסים לדף  Metrics explorer:

    כניסה לדף Metrics Explorer

    אם אתם משתמשים בשורת החיפוש כדי למצוא את הדף הזה, בחרו בתוצאה שכותרת המשנה שלה היא Monitoring.

  2. בסרגל הכלים של החלונית query-builder, לוחצים על הכפתור  PromQL.
  3. מזינים ומריצים את השאילתה הבאה:
    DCGM_FI_DEV_GPU_UTIL{cluster="CLUSTER_NAME", namespace="gmp-public"}
    

פתרון בעיות

למידע על פתרון בעיות בהטמעת מדדים, קראו את הקטע בעיות באיסוף ממייצאים במאמר פתרון בעיות בצד ההטמעה.