在训练任务期间,每60秒间隔进行一次查询。涉及命令如下:
cat /proc/cpuinfo | grep "processor" | wc -l
/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 -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时间戳,指标值],…] }
若采集的主机侧资源信息中包含较多异常数据,可能会导致后续故障诊断的设备资源分析结果异常,无法诊断实际问题。
存储示例如下:
{ "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"]] ... }