主机侧资源信息
文件说明
- 通过top命令或自动化脚本采集,监测主机已使用物理内存总量,各NPU卡训练及推理主进程使用的CPU占比(%CPU)、使用的物理内存(RES)等信息。以json文件统一存储,host_metrics_${core_num}.json。
- 命名约束:host_metrics_${core_num}.json。如host_metrics_64.json,其中64为CPU核数。
- 存放路径约束:
- 采集目录/environment_check/
- ${--env_check参数指定路径}/
- 详细说明请参考日志采集目录结构
采集方式说明
故障诊断工具支持通过以下方式采集主机侧资源信息:
- 脚本采集。在日志采集脚本中,使用host_resource_collect.py脚本采集主机侧资源信息。
- 命令采集。通过命令采集主机侧资源信息。
命令采集
- 开始训练及推理前,执行以下命令,查询训练设备的CPU总核数。
cat /proc/cpuinfo | grep "processor" | wc -l
- 训练及推理过程中,使用npu-smi info命令查询每张卡的进程ID,记录所有的进程的Process ID为{pid_list}。
/usr/local/bin/npu-smi info
回显如下:
+------------------------------------------------------------------------------------------------+ | npu-smi 23.0.rc3 Version: 23.0.rc2.3 | +---------------------------+---------------+----------------------------------------------------+ | NPU Name | Health | Power(W) Temp(C) Hugepages-Usage(page)| | Chip | Bus-Id | AICore(%) Memory-Usage(MB) HBM-Usage(MB) | +===========================+===============+====================================================+ | 0 xxx | OK | 73.4 44 1123 / 1123 | | 0 | 0000:C1:00.0 | 0 4565 / 15137 30710/ 32768 | +===========================+===============+====================================================+ | 1 xxx | OK | 69.6 39 1123 / 1123 | | 0 | 0000:81:00.0 | 0 4483 / 15137 30710/ 32768 | +===========================+===============+====================================================+ | 2 xxx | OK | 70.0 36 1123 / 1123 | | 0 | 0000:41:00.0 | 0 4437 / 15137 30710/ 32768 | +===========================+===============+====================================================+ | 3 xxx | OK | 69.6 44 1123 / 1123 | | 0 | 0000:01:00.0 | 0 3845 / 15039 30709/ 32768 | +===========================+===============+====================================================+ | 4 xxx | OK | 71.3 40 1123 / 1123 | | 0 | 0000:C2:00.0 | 0 4296 / 15137 30709/ 32768 | +===========================+===============+====================================================+ | 5 xxx | OK | 67.0 36 1123 / 1123 | | 0 | 0000:82:00.0 | 0 3758 / 15137 30709/ 32768 | +===========================+===============+====================================================+ | 6 xxx | OK | 71.7 37 1123 / 1123 | | 0 | 0000:42:00.0 | 0 4581 / 15137 30710/ 32768 | +===========================+===============+====================================================+ | 7 xxx | OK | 69.1 42 1123 / 1123 | | 0 | 0000:02:00.0 | 0 4690 / 15039 30710/ 32768 | +===========================+===============+====================================================+ +---------------------------+---------------+----------------------------------------------------+ | NPU Chip | Process id | Process name | Process memory(MB) | +===========================+===============+====================================================+ | 0 0 | 139667 | python | 30780 | +===========================+===============+====================================================+ | 1 0 | 139577 | python | 30782 | +===========================+===============+====================================================+ | 2 0 | 139446 | python | 30780 | +===========================+===============+====================================================+ | 3 0 | 139372 | python | 30780 | +===========================+===============+====================================================+ | 4 0 | 139258 | python | 30780 | +===========================+===============+====================================================+ | 5 0 | 139163 | python | 30780 | +===========================+===============+====================================================+ | 6 0 | 139126 | python | 30780 | +===========================+===============+====================================================+ | 7 0 | 139090 | python | 30780 | +===========================+===============+====================================================+
- 训练及推理过程中,通过top命令查询资源占用状况,记录“主机使用物理内存总量”、“各进程PID”、“各进程使用物理内存”、“各进程使用CPU占比”信息。
top -p {pid_list} -n 1 -b
命令示例如下:top -p 139667,139577,139446,139372,139258 ,139163,139126,139090 -n 1 -b
回显如下:
top - 14:15:53 up 39 days, 22:54, 9 users, load average: 28.32, 10.28, 5.44 Tasks: 2727 total, 9 running, 1261 sleeping, 1 stopped, 0 zombie %Cpu(s): 5.6 us, 5.4 sy, 0.0 ni, 89.0 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 80358528+total, 57884742+free, 70817856 used, 15392000+buff/cache KiB Swap: 0 total, 0 free, 0 used. 67941792+avail Mem PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 139667 root 20 0 8203.5g 3.4g 526208 R 309.5 0.4 1:46.26 python 139577 root 20 0 8203.5g 3.4g 526208 R 214.3 0.4 1:25.03 python 139446 root 20 0 8203.5g 3.4g 526144 R 204.8 0.4 1:54.20 python 139372 root 20 0 8203.5g 3.4g 526144 R 314.3 0.4 2:10.20 python 139258 root 20 0 8203.5g 3.4g 526144 R 209.5 0.4 1:23.53 python 139163 root 20 0 8203.5g 3.4g 526144 R 309.5 0.4 2:18.71 python 139126 root 20 0 8203.5g 3.4g 526144 R 109.5 0.4 0:58.54 python 139090 root 20 0 8203.5g 3.4g 526144 R 409.5 0.4 2:07.01 python
保存文件格式参考如下:
采集服务器的主机使用物理内存总量与训练及推理进程的PID,RES,%CPU信息,并按照[unix时间戳,数值信息]格式记录每一条信息。最终以json文件统一存储,文件名为host_metrics_${core_num}.json,按照如下格式保存所有信息:
host_metrics_${core_num}.json: { "node_mem_used": [[unix时间戳, 指标值],…], "node_rss_{pid}": [[unix时间戳, 指标值],…], "node_cpu_{pid}": [[unix时间戳, 指标值],…] }
- core_num:设备的CPU总核数。
- node_rss_${pid}:进程使用物理内存的指标列表,对应RES数据,按PID分组存储。
- node_cpu_${pid}:进程使用的cpu占比的指标列表,对应%CPU数据,按PID分组存储。
- node_mem_used:主机使用物理内存总量的指标列表,对应KiB Mem: xxx used。
若采集的主机侧资源信息中包含较多异常数据,可能会导致后续故障诊断的设备资源分析结果异常,无法诊断实际问题。
存储示例如下:
{ "node_mem_used": [[1689732534, 10259988480],[1689732594, 10259988481]], "node_rss_139667": [[1689732534, 353370112],[1689732594, 353370115]], "node_cpu_139667": [[1689732534, "12.0"],[1689732594, "13.0"]], "node_rss_139577": [[1689732534, 224591872],[1689732594, 224591877]], "node_cpu_139577": [[1689732534, "24.0"],[1689732594, "27.0"]], "node_rss_139446": [[1689732534, 127008768],[1689732594, 127008769]], "node_cpu_139446": [[1689732534, "16.0"],[1689732534, "19.0"]] ... }
父主题: 训练及推理中采集