前言

大家好,我是JACK,本篇是Linux命令系列第六篇,也是本系列的压轴篇。前几篇我们讲了通用Linux命令,这篇专门讲昇腾NPU和鲲鹏CPU相关的专项命令,结合实际测试经验来讲。


一、环境确认

在使用昇腾和鲲鹏专项命令之前,先确认环境是否正常:

# 确认昇腾卡是否识别
[root@localhost ~]# lspci | grep -i ascend
0000:04:00.0 Processing accelerators: Huawei Technologies Co., Ltd. Ascend 300I
0000:05:00.0 Processing accelerators: Huawei Technologies Co., Ltd. Ascend 300I
0000:06:00.0 Processing accelerators: Huawei Technologies Co., Ltd. Ascend 300I
0000:07:00.0 Processing accelerators: Huawei Technologies Co., Ltd. Ascend 300I
0000:08:00.0 Processing accelerators: Huawei Technologies Co., Ltd. Ascend 300I
0000:09:00.0 Processing accelerators: Huawei Technologies Co., Ltd. Ascend 300I
0000:0a:00.0 Processing accelerators: Huawei Technologies Co., Ltd. Ascend 300I
0000:0b:00.0 Processing accelerators: Huawei Technologies Co., Ltd. Ascend 300I
# 8张卡全部识别 ✅

# 确认鲲鹏CPU架构
[root@localhost ~]# lscpu | grep Architecture
Architecture: aarch64
# aarch64确认是ARM架构鲲鹏CPU ✅

# 确认操作系统版本
[root@localhost ~]# cat /etc/os-release
NAME="openEuler"
VERSION="22.03 (LTS-SP3)"
# 信创常用openEuler或麒麟、统信操作系统

二、npu-smi — NPU状态查看

npu-smi是昇腾NPU最常用的管理工具,类似英伟达的nvidia-smi。

# 查看所有NPU基本信息
[root@localhost ~]# npu-smi info
+-------------------------------------------------------------------------------------------+
| npu-smi 22.0.0                                       Driver Version: 22.0.0              |
+-------------------------------------------------------------------------------------------+
| NPU   Name            Health  Power(W)  Temp(C)  HBM-Usage(MB)  Aicore(%)  Aicpu(%)     |
| Chip                                                                                      |
+==========================================================================================+
| 0     310P3           OK      67.4      42        0/ 32768        0          0           |
| 0                                                                                         |
+==========================================================================================+
| 1     310P3           OK      66.8      41        0/ 32768        0          0           |
| 1                                                                                         |
+==========================================================================================+

# 查看指定卡详细信息
[root@localhost ~]# npu-smi info -i 0
Board ID                       : 0x2b
PCIe Bus Info                  : 0000:04:00.0
NPU ID                         : 0
Health Status                  : OK
Temperature(C)                 : 42
Power(W)                       : 67.4
HBM Capacity(MB)               : 32768
HBM Usage(MB)                  : 0
Aicore Utilization(%)          : 0
Aicpu Utilization(%)           : 0

# 实时监控所有NPU状态(每2秒刷新)
[root@localhost ~]# npu-smi info -t common -i 0,1,2,3,4,5,6,7 -d 2

重点关注字段:

字段 说明
Health OK表示正常,Warning/Error需要排查
Power(W) 当前功耗,压测时会升高
Temp(C) 温度,正常不超过85℃
HBM-Usage 显存使用情况
Aicore(%) AI核心利用率,压测时应接近100%

三、ascend-dmi — NPU性能测试

ascend-dmi是昇腾官方性能测试工具,可以测试NPU的算力。

# INT8算力测试(单卡)
[root@localhost ~]# ascend-dmi -f -d 0 -t int8 --et 60
This test will affect the business on this server. Do you want to continue?(Y/N)y
-----------------------------------------------------------------------------------------
    Device    Execute Times    Duration(ms)    TOPS@INT8    Power(W)
-----------------------------------------------------------------------------------------
    0         360,000,000      1857            558.164      216.4
-----------------------------------------------------------------------------------------

# FP16算力测试(单卡)
[root@localhost ~]# ascend-dmi -f -d 0 -t fp16 --et 60
-----------------------------------------------------------------------------------------
    Device    Execute Times    Duration(ms)    TFLOPS@FP16    Power(W)
-----------------------------------------------------------------------------------------
    0         360,000,000      1857            287.563        174.4
-----------------------------------------------------------------------------------------

8张卡批量测试脚本:

# 循环跑8张卡INT8算力测试,结果保存到文件
for i in {0..7}
do
    echo "=== 测试卡 $i ===" | tee -a all_cards_int8.txt
    ascend-dmi -f -d $i -t int8 --et 60 | tee -a all_cards_int8.txt
done

算力参考标准(Atlas 300I):

精度 理论峰值 正常达成率
INT8 576 TOPS ≥95%
FP16 288 TFLOPS ≥95%

四、温度和功耗监控

压测昇腾卡期间必须同步监控温度和功耗:

# 方式一:npu-smi实时监控
[root@localhost ~]# watch -n 5 'npu-smi info' >> npu_monitor.txt

# 方式二:ipmitool查看传感器
[root@localhost ~]# ipmitool sensor list | grep -i npu
NPU0_Temp        | 45.000     | degrees C | ok
NPU1_Temp        | 44.000     | degrees C | ok
NPU2_Temp        | 46.000     | degrees C | ok
NPU3_Temp        | 45.000     | degrees C | ok

# 持续采集NPU温度日志
[root@localhost ~]# watch -n 5 'ipmitool sensor list | grep -i npu' >> npu_temp_log.txt

五、鲲鹏CPU专项命令

# 查看鲲鹏CPU详细信息
[root@localhost ~]# lscpu
Architecture:    aarch64
CPU(s):          128
Model name:      Kunpeng-920
CPU MHz:         2600.000
NUMA node(s):    4

# 查看CPU当前频率
[root@localhost ~]# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
2600000
# 2600000 = 2600MHz,确认频率正常

# 查看CPU调速策略
[root@localhost ~]# cpupower frequency-info
analyzing CPU 0:
  current policy: frequency should be within 1.0 GHz and 2.6 GHz
  current CPU frequency: 2.60 GHz (asserted by call to hardware)
  current policy: performance
# 压测时确认是performance模式

# 查看NUMA拓扑
[root@localhost ~]# numactl --hardware
available: 4 nodes (0-3)
node 0 cpus: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
node 0 size: 128938 MB
node 1 cpus: 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
node 1 size: 131072 MB
# 鲲鹏920双路服务器有4个NUMA节点,内存访问跨节点会影响性能

六、常见问题及排查

1. NPU卡识别不全

# 确认识别数量
[root@localhost ~]# lspci | grep -i ascend | wc -l
4
# 只识别到4张,实际安装8张

# 查看dmesg报错
[root@localhost ~]# dmesg | grep -i pcie
[    3.256789] pcie 0000:08:00.0: PCIe link down

# 检查拓扑图接线是否正常
# 进BIOS确认PCIe识别情况
# 更新BMC固件版本

2. NPU算力达不到标准

# 先确认卡的健康状态
[root@localhost ~]# npu-smi info
# 确认Health为OK

# 查看温度是否过高
[root@localhost ~]# npu-smi info -i 0 | grep Temp
Temperature(C) : 89
# 温度超过85℃,热降频导致算力下降
# 检查散热和机房环境温度

# 确认驱动版本
[root@localhost ~]# npu-smi info | grep Driver
Driver Version: 22.0.0
# 驱动版本过低也会影响算力,考虑更新

3. ascend工具安装失败

这是初次配置昇腾环境常见问题,安装失败通常是驱动版本不匹配:

# 查看当前驱动版本
[root@localhost ~]# npu-smi info | grep Driver
Driver Version: 22.0.0

# 确认ascend工具包版本和驱动版本匹配
# 去昇腾论坛下载对应版本的工具包
# 参考官方手册重新安装

4. 鲲鹏CPU压力跑不上去

# 确认CPU频率是否在performance模式
[root@localhost ~]# cpupower frequency-info | grep policy
current policy: performance

# 如果不是performance模式,切换
[root@localhost ~]# cpupower frequency-set -g performance

# 确认所有核心都在跑
[root@localhost ~]# htop
# 用htop查看每个核心使用率是否都跑满

七、测试标准流程总结

昇腾鲲鹏服务器完整测试流程:

# 1. 测试前清空日志
dmesg -c
ipmitool sel clear

# 2. 确认硬件识别
lspci | grep -i ascend    # 确认NPU卡数量
lscpu                      # 确认CPU信息
npu-smi info               # 确认NPU健康状态

# 3. 跑算力测试
for i in {0..7}; do
    ascend-dmi -f -d $i -t int8 --et 60 | tee -a int8_result.txt
done

# 4. 同步监控温度
watch -n 5 'npu-smi info' >> npu_monitor.txt
watch -n 5 'ipmitool sensor list | grep -i temp' >> temp_log.txt

# 5. 测试后保存日志
dmesg > dmesg_final.txt
ipmitool sel list > sel_final.txt

八、总结

昇腾鲲鹏专项命令核心工具:

  • npu-smi — 实时监控NPU状态、温度、功耗、利用率
  • ascend-dmi — 测试NPU算力,验证INT8/FP16达成率
  • lscpu + cpupower — 确认鲲鹏CPU频率和调速策略
  • numactl — 查看NUMA拓扑,优化内存访问性能

至此Linux命令系列六篇全部完成!后续会继续出专题深入篇,敬请期待!

欢迎关注JACK的服务器笔记

Logo

昇腾计算产业是基于昇腾系列(HUAWEI Ascend)处理器和基础软件构建的全栈 AI计算基础设施、行业应用及服务,https://devpress.csdn.net/organization/setting/general/146749包括昇腾系列处理器、系列硬件、CANN、AI计算框架、应用使能、开发工具链、管理运维工具、行业应用及服务等全产业链

更多推荐