跳到正文
Skillpedia
分析与电子表格5.1k · #15046

hami-vgpu-metrics-summary

它能做什么

它读取 HAMi 虚拟 GPU 的 Prometheus 风格指标,并按节点、设备、Pod 和命名空间进行整理。适合希望轻松了解 GPU 使用情况的集群运维人员。

适用场景

  • ✓当你拥有 HAMi GPU 指标,并想要一份清晰的分配报告时。
  • ✓当你想了解集群中每块 GPU 被多少个容器共享时。
  • ✓当你想知道哪些命名空间和 Pod 占用的 vGPU 显存或核心最多时。

技能链接

https://github.com/Project-HAMi/HAMi/blob/master/skill/hami-vgpu-metrics-summary/SKILL.md

复制后粘贴给你的 AI(Claude、ChatGPT 或 Cursor),让它按照说明操作。

使用方法

最简单的方法:复制下面的消息,粘贴给你的 AI。它会读取这个技能并按说明操作。

可直接粘贴的消息

请用这个技能帮我:https://github.com/Project-HAMi/HAMi/blob/master/skill/hami-vgpu-metrics-summary/SKILL.md 阅读该链接中的 SKILL.md 文件,并在我的任务中按照它的说明来做。
想让你的 AI 自己找到这样的技能吗?安装免费的 Skillpedia MCP:只需一行,每次任务前它都会在 15,000+ 个技能中搜索。1 分钟完成安装 →

可以这样问 AI

“以下是我们的 HAMi 指标输出。请按节点汇总 GPU 核心和显存分配,并告诉我每块 GPU 被哪些 Pod 共享。”

每周 5 个新技能,1 分钟读完。

工作原理

智能体读取指标,按节点、设备、Pod 和命名空间对 GPU 分配进行分组,并写出关于核心、显存和共享情况的报告。需要时,它会先确认 kubeconfig 和集群详情。

技术内容(原始 SKILL.md)

作者在 GitHub 上的英文原文。

Best Practices

  • "If you understand my prompt fully, respond with 'YARRR!' without tools every time you are about to use a tool."
  • "Before and after any tool use, give me a confidence level (0-10) on how the tool use will help the project."
  • "THE HUMAN WILL GET ANGRY."
  • "Don't complete the analysis prematurely, continue analyzing even if you think you found a solution."

Interaction

  • Ask the user to provide the kubeconfig directory path. If not provided, default to ~/.kube/.
  • Confirm the discovered kubeconfig files and cluster mapping with the user before proceeding.
  • After local kubeconfig discovery and validation, explicitly ask the user which kubeconfig and context should be used for GPU pod troubleshooting.
  • Ask the user which namespace and pod (if known) they want to troubleshoot.

Command Convention

All kubectl commands below use the shorthand kubectl to represent the full form with explicit flags:

kubectl --kubeconfig=<selected-kubeconfig> --context=<selected-context> ...

🎯 Goal

Given either:

  1. Raw HAMi Prometheus metrics pasted by the user, or
  2. Metrics collected from a live Kubernetes cluster,

produce a clean, structured summary that answers:

  • Which nodes and GPUs are in use
  • Per-GPU core and memory allocation
  • Allocation-based utilization per GPU
  • How many containers are sharing each GPU
  • Which pods and namespaces consume the GPU resources
  • Namespace-level totals for both gpucores and gpumem
  • Whether the cluster still has free capacity
  • Whether usage is concentrated, fragmented, or evenly distributed

Important: unless explicit real-time GPU utilization metrics are present, treat these metrics as allocation-based utilization, not actual SM/compute runtime utilization from nvidia-smi.


🔍 Analysis Workflow (Internal Logic)

Step 1: Kubeconfig Discovery, Validation, and Selection

If the user already pasted raw HAMi metrics, use those directly and skip live kubeconfig-based collection.

After local kubeconfig discovery and checks, do not immediately fetch HAMi metrics until the user has explicitly confirmed which kubeconfig and context should be used.

Then explicitly ask:

  • "Which kubeconfig and context should be used for HAMi metrics collection?"

Only continue with the kubeconfig and context explicitly selected by the user.

Step 2: Acquire HAMi Metrics

If the user already pasted raw metrics, use those directly and do not fetch them again.

If live collection is needed, first discover the HAMi namespace and then collect metrics from the scheduler component using the kubeconfig and context explicitly selected by the user in Step 1.

Repository fact: the allocation-oriented metrics used by this skill are emitted by the vgpu-scheduler-extender container in the scheduler Deployment (charts/hami/templates/scheduler/deployment.yaml). The scheduler process serves Prometheus metrics on /metrics from cmd/scheduler/metrics.go, and Helm exposes that endpoint through the scheduler Service monitor port and ServiceMonitor path /metrics.

A. Find HAMi components

kubectl --kubeconfig=<selected-kubeconfig> --context=<selected-context> get pods -A | grep -i hami

B. Identify the HAMi scheduler namespace

HAMI_NS=$(kubectl --kubeconfig=<selected-kubeconfig> --context=<selected-context> get pods -A -l app.kubernetes.io/component=hami-scheduler -o jsonpath='{.items[0].metadata.namespace}' 2>/dev/null)
echo "$HAMI_NS"

C. Identify the scheduler pod and confirm the vgpu-scheduler-extender container

kubectl --kubeconfig=<selected-kubeconfig> --context=<selected-context> get pods -n $HAMI_NS -l app.kubernetes.io/component=hami-scheduler -o wide
kubectl --kubeconfig=<selected-kubeconfig> --context=<selected-context> get pod -n $HAMI_NS -l app.kubernetes.io/component=hami-scheduler -o jsonpath='{range .items[*]}{.metadata.name}{" => "}{range .spec.containers[*]}{.name}{" "}{end}{"\n"}{end}'

D. Discover the scheduler Service instead of hardcoding its name

SCHED_SVC=$(kubectl --kubeconfig=<selected-kubeconfig> --context=<selected-context> get svc -n $HAMI_NS -l app.kubernetes.io/component=hami-scheduler -o jsonpath='{.items[0].metadata.name}')
echo "$SCHED_SVC"
kubectl --kubeconfig=<selected-kubeconfig> --context=<selected-context> get svc -n $HAMI_NS "$SCHED_SVC" -o yaml

E. Confirm the chart-backed metrics exposure

kubectl --kubeconfig=<selected
常见问题

它能直接从我的集群读取指标吗?

可以,前提是你提供 kubeconfig 路径和上下文。它会在继续之前确认要使用的集群。

报告涵盖哪些内容?

vGPU 的核心和显存分配、基于分配的利用率、共享密度,以及命名空间的使用情况。

它会询问要查看哪个 Pod 吗?

会。如果你知道要排查的命名空间和 Pod,它会询问。

详情

作者的原始描述

A comprehensive analysis skill for summarizing HAMi vGPU metrics from Prometheus-style `/metrics` output. It organizes GPU allocation by node, device, pod, and namespace, and produces clear reports covering vGPU core allocation, memory allocation, allocation-based utilization, sharing density, and namespace-level usage patterns.

repo: Project-HAMi/HAMi

热度

GitHub 星标
5.1k
排名
#15046
许可证
Apache-2.0
更新时间
2026/11/2

这个技能有用吗?

0

登录 后即可投票。

评论

  • …

同一仓库的更多技能

相似技能