NVIDIA-SMI系列命令详解(11)-统计信息

1,668 阅读6分钟

统计信息(STATISTICS: (EXPERIMENTAL))

本文为NVIDIA-SMI系列命令详解第十一篇-统计信息,介绍和演示了nvidia-smi 命令的统计信息相关参数,介绍了如下命令:

nvidia-smi stats [选项]

生成 GPU 统计信息数据,例如功率采样、利用率采样、xid 事件、时钟更改事件和性能上限事件。

统计信息选项,支持的参数列表如下:

    [-i | --id]: 驱动程序返回的自然枚举中 GPU 的从 0 开始的索引、
                 GPU 的板序列号、GPU 的 UUID 或 GPU 的 PCI 总线 ID. 
                 如果需要指定多个设备,可以使用逗号","将不同的id隔开。
    [-f | --filename]: 输出日志到特定的文件。
    [-d | --display]: 展示特定的指标项. 可以使用逗号","将不同的指标项隔开,
                      支持的指标项列表如下:
                      pwrDraw,temp,memUtil,gpuUtil,
                      encUtil,decUtil,memClk,procClk,
                      violPwr, violThm, xidEvent
    [-c | --count]: 运行特定次数的监控循环,然后退出。
    [-h | --help]: 展示帮助信息

注意:

命令行在循环模式下工作,直到按下 Ctrl+C。

启动命令行时,违规功率上限时间和违规热上限标志会重置。

在 Linux 下的 Kepler 或更新的 GPU 上受支持

支持 Tesla、GRID 和 Quadro 产品

实验功能

统计输出信息各字段解释

统计信息以如下CSV格式输出

Device, Power Drawn (pwrDraw), Timestamp (us), Value (Watts)
Device, GPU Temperature (temp), Timestamp (us), Value (C)
Device, GPU Util (gpuUtil), Timestamp (us), Value (%)
Device, Memory Util (memUtil), Timestamp (us), Value (%)
Device, Encoder Util (encUtil), Timestamp (us), Value (%)
Device, Decoder Util (decUtil), Timestamp (us), Value (%)
Device, Processor clock (procClk), Timestamp (us), Value (MHz)
Device, Memory clock (memClk), Timestamp (us), Value (MHz)
Device, Violation Pwr Cap (violPwr), Timestamp (us), Viol time (ns)
Device, Violation Therm Cap (violThm), Timestamp (us), Viol bool (1/0)
Device, Xid event (xidEvent), Timestamp (us), Xid error number

对应解释如下表所示:

设备id值项及其含义打点Unix时间戳采样值(单位)
Device设备idPower Drawn (pwrDraw)功耗 (pwrDraw)Timestamp (us)时间戳 (us)Value (Watts)值 (Watts)
Device设备idGPU Temperature (temp)GPU 温度 (temp)Timestamp (us)时间戳 (us)Value (C)值 (C)
Device设备idGPU Util (gpuUtil)GPU Util (gpuUtil)Timestamp (us)时间戳 (us)Value (%)值 (%)
Device设备idMemory Util (memUtil)内存利用率 (memUtil)Timestamp (us)时间戳 (us)Value (%)值 (%)
Device设备idEncoder Util (encUtil)编码器利用率encUtil)Timestamp (us)时间戳 (us)Value (%)值 (%)
Device设备idDecoder Util (decUtil)解码器利用率 (decUtil)Timestamp (us)时间戳 (us)Value (%)值 (%)
Device设备idProcessor clock (procClk)处理器时钟 (procClk)Timestamp (us)时间戳 (us)Value (MHz)值 (MHz)
Device设备idMemory clock (memClk)内存时钟 (memClk)Timestamp (us)时间戳 (us)Value (MHz)值 (MHz)
Device设备idViolation Pwr Cap (violPwr)违规功率上限 (violPwr)Timestamp (us)时间戳 (us)Viol time (ns)违规时间 (ns)
Device设备idViolation Therm Cap (violThm)违规热上限 (violThm)Timestamp (us)时间戳 (us)Viol bool (1/0)是否违规(1/0)
Device设备idXid event (xidEvent)Xid 事件(xidEvent)Timestamp (us)时间戳 (us)Xid error numberXid 错误号

-i 指定GPU

id是驱动程序返回的自然枚举中 GPU 的从 0 开始的索引、GPU 的板序列号、GPU 的 UUID 或 GPU 的 PCI 总线 ID。 如果需要指定多个设备,可以使用逗号","将不同的id隔开。

运行示例

查看设备id为0的设备统计信息 运行示例:

nvidia-smi stats -i 0

image

可以看到,

在1658754734391792 unix time GPU温度为 35度

Violation Power Cap Time的值violPwr被设置了为0

Violation Thermal Cap flag的值violThm被设置了为0

后续一系列pwrDraw值为功率在不同Unix time的打点值。

image

后续还有一些其它打点值分别为:

  • memUtil:显存使用率

  • gpuUtil:GPU使用率

  • encUtil:编码利用率

  • decUtil:解码利用率

-f 将查询输出重定向到指定文件以代替默认标准输出

将查询输出重定向到指定文件以代替默认标准输出。指定的文件将被覆盖。

运行示例

设备id为0的GPU统计信息输出到文件out.log中

nvidia-smi stats -i 0 -f out.log

image

可以看到,必须按住 Ctrl + C 才能终止命令,否则命令会一直执行。

out.log文件中的内容与控制台输出的一致。

-d 展示特定的采样项

运行示例

展示设备为0的GPU的 temp、violThm 信息

nvidia-smi stats -i 0 -d temp,violThm

image

-c 执行指定次数监控循环后退出

运行示例

展示设备为0的GPU的 temp、pwrDraw 信息 5 次之后退出

nvidia-smi stats -i 0 -d temp,violThm -c 5

image

可以看到,加上-c 5参数之后,运行5次采样后程序退出,不会像之前的命令需要执行 Ctrl + C 后才能退出。

-h 打印帮助信息

运行示例

展示nvidia-smi stats的帮助信息

nvidia-smi stats -h

image

对应内容如下:

root@YellowMeta-T4:~# nvidia-smi stats -h

stats -- Generates GPU statistics such as power samples,
         utilization samples, xid events, clock change events
         and performance capping events

Supported on Kepler or newer GPUs under Linux
Supported on Tesla, GRID and Quadro products
Experimental Feature

Usage: nvidia-smi stats [options]

Options include:
    [-i | --id]: Enumeration index, PCI bus ID or UUID. Provide comma
                 separated values for more than one device
    [-f | --filename]: Log to a specified file, rather than to stdout
    [-d | --display]: Display specific metric. Provide comma separated
                      values from pwrDraw,temp,memUtil,gpuUtil,
                      encUtil,decUtil,memClk,procClk,violPwr,
                      violThm and xidEvent
    [-c | --count]: Run for specified number of monitoring cycles and exit
    [-h | --help]: Display help information

Stats in following CSV format:
Device, Power Drawn (pwrDraw), Timestamp (us), Value (Watts)
Device, GPU Temperature (temp), Timestamp (us), Value (C)
Device, GPU Util (gpuUtil), Timestamp (us), Value (%)
Device, Memory Util (memUtil), Timestamp (us), Value (%)
Device, Encoder Util (encUtil), Timestamp (us), Value (%)
Device, Decoder Util (decUtil), Timestamp (us), Value (%)
Device, Processor clock (procClk), Timestamp (us), Value (MHz)
Device, Memory clock (memClk), Timestamp (us), Value (MHz)
Device, Violation Pwr Cap (violPwr), Timestamp (us), Viol time (ns)
Device, Violation Therm Cap (violThm), Timestamp (us), Viol bool (1/0)
Device, Xid event (xidEvent), Timestamp (us), Xid error number

Example Command Line:
nvidia-smi stats : Stats for all the devices
nvidia-smi stats -d pwrDraw : Only pwr stats for all devices
nvidia-smi stats -i 0 : All stats for device 0
nvidia-smi stats -i 0 -d pwrDraw : Pwr stats for device 0
nvidia-smi stats -d pwrDraw,gpuUtil : Pwr and GPU util stats for all devices
nvidia-smi stats -i 0,1 : Stats for device 0 and device 1

Examples:
0, pwrDraw , 1391033793936268, 26
0, temp    , 1391033798413909, 28
1, gpuUtil , 1391033834431128, 10
0, memUtil , 1391033839106743, 30
0, encUtil , 1391033839106743, 10
0, decUtil , 1391033839106743, 10
0, procClk , 1390937927961817, 648
2, violPwr , 1391038834441332, 135000123
0, xidEvent, 1390939927921817, 31

Notes:
- The command line works in looping mode until Ctrl+C is pressed.
- Violation Power Cap Time and Violation Thermal Cap flag resets when
  the command line is initiated.