[NVSentinel] gpu-health-monitor模块之dcgm_watcher

NVSentinel gpu-health-monitor模块之dcgm_watcher

dcgm.py 是 GPU Health Monitor 的核心:通过 DCGM 周期性检查 GPU/Switch 健康,并把结果异步通知回调(如 Platform Connector)。

整体定位

DCGMWatcher 负责:

  1. 连接 DCGM(远程服务或进程内 embedded hostengine)
  2. 创建包含所有 GPU + NVSwitch 的 monitoring group
  3. 按间隔跑 health check,可选评估热裕度
  4. 过滤需抑制的错误码
  5. 通过 CallbackInterface 把结果发出去

数据流大致是:

markdown 复制代码
DCGM ←→ DCGMWatcher.start() 轮询循环
              ↓
     health_status + gpu_ids
              ↓
     CallbackInterface(如 PlatformConnector)

模块组成

1. 连接方式:_create_dcgm_handle / _run_dcgm_server

两种 mode:

Mode 行为
local-managed 进程内起 embedded DCGM,再把 hostengine 暴露到 loopback TCP
默认 remote 用 addr 连已有 DCGM(K8s DCGM Exporter/服务或本机地址)

_run_dcgm_server 兼容 DCGM 4.x(dcgmServerRun)和 3.3.7(dcgmEngineRun)。

2. 能力发现

构造时会扫描 DCGM Python bindings:

  • _get_available_health_watches:所有 DCGM_HEALTH_WATCH_*
  • _get_available_error_codes:所有 DCGM_FR_* 错误码(会绕过 bindings 里已知的重复定义 bug)

用于把 DCGM 数值映射成可读的 watch / error 名称。

3. 健康检查:_perform_health_check

核心逻辑:

  1. 调用 dcgm_group.health.Check()
  2. 遍历 incidents,按 watch + GPU 聚合错误信息(多条 message 用 ; 拼接)
  3. 输出 dict[watch_name → HealthDetails]
  4. timeout / 异常时标记 connectivity_success=False,触发重连

4. 可选热裕度监控:_evaluate_gpu_thermal_margin

若启用 thermal_margin_enabled 且 bindings 有 field 153(DCGM_FI_DEV_GPU_TEMP_TLIMIT):

  • 订阅该 field
  • 用 MetadataReader 读每张卡的 HW slowdown T.Limit
  • 当 margin < slowdown_threshold 时记为 GPU_TEMP_HW_SLOWDOWN_VIOLATION

这是独立于标准 DCGM_HEALTH_WATCH_* 的自定义监视,通过 DCGM_FIELDS_MONITORING 注册表扩展。

5. 错误抑制:_suppress_configured_error_codes

对配置里 suppressed_error_codes 中的高频、不可操作事件:从 failures 里删掉;若该 watch 不再有 failure,状态改回 PASS。

6. 回调:_fire_callback_funcs

用线程池异步调用每个 callback,避免阻塞轮询;成功/失败记 Prometheus metrics。

接口在 types.py:

  • health_event_occurred(health_details, gpu_ids)
  • dcgm_connectivity_failed()

7. 主循环:start

vbnet 复制代码
while not exit:
    wait(poll_interval)
    if 无 handle:
        连接 + 初始化 group / field watch
        失败 → dcgm_connectivity_failed
    else:
        health check
        连通失败 → 清理资源,置空 handle(下轮重连)
        成功 → 热裕度评估 → 抑制错误 → health_event_occurred
finally:
    cleanup + 关闭线程池

初始化失败会 rollback(unwatch / delete field group / delete group),避免 DCGM 服务端资源泄漏。


关键类型(types.py)

  • HealthStatus:PASS / WARN / FAIL
  • HealthDetails:某 watch 的整体状态 + entity_failures[gpu_id]
  • ErrorDetails:错误码 + 消息
  • DCGMFieldMonitor:自定义 field 监视配置
  • CallbackInterface:下游消费方契约

一句话总结

这个文件把 DCGM 采数/健康检查 做成可重连的轮询 watcher,再通过回调把「哪些 GPU、哪些 watch 出了什么问题」交给上层(Platform Connector)去做事件上报与处置。

相关推荐
云和数据.ChenGuang4 分钟前
print(f“a+b=“,result) print(f“a+b={result}“)区别
java·前端·人工智能·python·深度学习
roman_日积跬步-终至千里8 分钟前
【数据Agent论文·查询与语义|11】EntSQL:给了业务文档,模型为何还是写不对SQL?
数据库·人工智能·sql·数据分析
一木 之林15 分钟前
LangChain 第9章 RAG 与项目实战:文档切分、嵌入、Milvus 与客服知识库
人工智能·计算机视觉·langchain·milvus
水如烟21 分钟前
孤能子视角:EIS术语梳理·术层+吐纳——操作语法与收束:从投射到呼吸节律
人工智能
偷吃米饭27 分钟前
图片特征怎么描述?用华为云码道开发 OpenCV ORB 特征提取工具
人工智能·opencv·华为云
risc12345632 分钟前
万变不离其宗
人工智能·低代码·云原生
科技看点说40 分钟前
SAP B1如何支撑高科技与精密制造?项目、物料、委外与成本管理解析
大数据·人工智能
skywalk816341 分钟前
FreeBSD系统在Deepseek-harness中配置使用其它几家的模型,比如hy3 hunyuan-2 glm5.3-flash等
人工智能·freebsd·deepseek·harness
马六六i42 分钟前
目前知名的分布式Ai数智共享商城哪家好
人工智能·分布式
愈努力俞幸运44 分钟前
Oauth登录
人工智能