使用msaicerr工具分析AI Core Error问题
使用约束
- 该工具仅支持本地分析使用,即部署该工具的环境应该和日志所在环境为同一环境(运行环境)。
- 该工具依赖python3.7.5或以上版本,在安装该工具的环境中需提前安装python。
- 该工具不支持在RC模式下使用:
- 该工具暂不支持分析以下算子的AI Core Error问题:
- Foreach类算子
- GroupedMatmul
- NonFiniteCheck
- GroupedMatMulAllReduce
- FusedInferAttentionScore
- ScatterList
- IncreFlashAttention
- MemSet
- NonMaxSuppressionBucketize
前提条件
已在CANN运行环境上安装toolkit包。详细安装请参见《CANN软件安装指南》。
已配置CANN基础环境变量。安装CANN软件后,使用CANN运行用户编译、运行时,需要以CANN运行用户登录环境,执行. ${install_path}/set_env.sh命令设置环境变量。其中${install_path}为CANN软件的安装目录。
在使用msaicerr工具前,在“Toolkit包安装路径{$install_path}/tools/msaicerr”目录下获取msaicerr.py。
使用msaicerr工具分析
- 以运行用户登录Host服务器。
- 使用msaicerr工具快速定位AI Core Error问题的关键原因。
进入“Toolkit包安装路径{$install_path}/tools/msaicerr”目录,根据收集AI Core Error问题信息中收集的信息,执行以下命令提取AI Core Error问题相关的关键信息。以下命令中aic_err_info为存放AI Core Error问题信息的目录,请根据实际情况替换。
python3 msaicerr.py -p aic_err_info
- 若执行msaicerr工具失败:
- 检查使用工具的前提条件是否满足、收集AI Core Error问题信息中收集的信息是否完整;
- 再参见算子输入args错误排查算子参数问题;
- 如果依然定位不了问题再联系技术支持。
- 如果执行msaicerr.py脚本报错“ModuleNotFoundError: No module named 'google'”,是由于缺少protobuf库(用于存储数据的一种数据格式),需使用pip3 install protobuf --user命令安装protobuf库后,再执行脚本。
- 如果执行msaicerr.py脚本报错“ModuleNotFoundError: No module named 'chardet'”,是由于缺少chardet库(用于检测字符编码),需使用pip3 install chardet --user命令安装chardet库后,再执行脚本。
- 如果执行msaicerr.py脚本报错“ModuleNotFoundError: No module named 'bfloat16ext'”,是缺少bfloat16ext库(用于解析bf16类型的数据),需使用pip3 install bfloat16ext --user命令安装bfloat16ext库后,再执行脚本。
另外,可以使用命令python3 msaicerr.py -h,查看具体参数的含义。
执行命令成功后,在执行命令的同级目录下生成“info_{时间戳}/{aicore_{number}_{时间戳}/info.txt”文件以及异常算子测试文件test_single_op.py(该文件仅在有异常算子时才存在)。
用户可以直接通过info.txt文件进行问题分析和定位,重点关注Root cause conclusion处包含的关键信息,如下表所示。若故障信息中存在多个AI Core Error问题,则msaicerr工具按日志时间解析第一次出现的AI Core Error问题。
表1 Root cause conclusion处包含的关键信息 关键信息
问题原因
典型案例及处理方法
Golden Op run error on your environment.
环境异常。
Single op test aicore error, please check op.
单算子实现异常或编译过程异常。
根据提示信息分析是用户自定义算子,还是cann内置算子。
如果打屏日志中有如下提示,表示工具自动生成了单算子用例脚本,您可以执行该脚本复现单算子问题,则根据提示排查问题,如果复现不了问题或者排查不出问题,请联系技术支持。
Run 'cd /usr/local/Ascend/CANN-7.3/tools/msaicerr;python3 /home/xxxxxxx/tf/info_20240423005946/aicerror_0_20240306035524/test_single_op.py' can test op!
Atomic accumulation exception
由于精度问题导致溢出。
The addr of input/output is used but not alloc
算子输入输出数据地址异常。
The args of op is diffrerent before and after execute
算子输入输出参数异常。
Dump data failed in exception dump! Address of input or output is error!
框架分配内存问题,此时需要区分是GE或其它框架,联系技术支持处理。
There's no obvious known error, so I can't determine what the error is.
msaicerr工具执行成功,但没有解析出来故障
联系技术支持处理。
info.txt文件示例如下:
Analysis result: success. ***********************Root cause conclusion******************** Atomic accumulation exception, please check the input data. According to the precision problem. Check the network accuracy. ***********************1. Basic information******************** # 本环节为aicore error的基本信息 error time : 2022-03-05-17:30:51.327.642 device id : 0 core id : 0 task id : 3 stream id : 1 node name : L2Loss kernel name : te_l2loss_0a9b2632fc2241e91c70b5a3ed5df7a95ba5024113b21f413c84e2bbb8171102_1 ***********************2. AICERROR code*********************** # 本环节为aicore错误码以及代表的错误信息 code : 0x800000 error bits : MTE_ERR_INFO: 0x600004a mte_err_type bit[26:24]=110 meaning:write bus error, 写请求时数据异常,例如安全访问请求访问了非安全的地址,非安全访问的请求访问了安全地址,访问请求收不到response、atomic运算异常(1980) mte_err_addr bit[22:8]=000000000000000 meaning:MTE Error Address [19:5] approximate:0x0 ***********************3. Instructions************************ # 本环节为aicore error发生的地址信息,并尽力去分析错误的cce行号与对应的算子行号 start pc : 0x1000120040026000 current pc : 0x120040026968 Error occured most likely at line: 928 /home/HwHiAiUser/tools/msaicerr/info_20220314203506/aicerror_0_20220305173051/te_l2loss_0a9b2632fc2241e91c70b5a3ed5df7a95ba5024113b21f413c84e2bbb8171102_1.o.txt:928 /home/HwHiAiUser/tf/kernel_meta_21663_1646472642284609050/kernel_meta/te_l2loss_0a9b2632fc2241e91c70b5a3ed5df7a95ba5024113b21f413c84e2bbb8171102_1.cce:135 related instructions (error occured before the mark *): 944: <not available> 948: <not available> 94c: <not available> 950: <not available> 954: <not available> 958: <not available> 95c: <not available> 960: <not available> 964: <not available> * 968: <not available> For complete instructions, please view /home/HwHiAiUser/tools/msaicerr/info_20220314203506/aicerror_0_20220305173051/te_l2loss_0a9b2632fc2241e91c70b5a3ed5df7a95ba5024113b21f413c84e2bbb8171102_1.o.txt ****************4. Input and output of node******************* # 本环节用于分析aicore error时用的地址是否越界。 # - 获取aicore error时input output的地址信息 # - 获取aicore error时系统分配的内存范围。 # - 检查input、output地址信息是否在地址范围内。若不在,则报错。 input[0] addr: 0x1202017a7000 end_addr:0x120202f4db00 size: 0x17a6b00 output[0] addr: 0x12004001d000 end_addr:0x12004001d004 size: 0x4 workspace_bytes:0 avaliable addrs: start_addr end_addr size 0x120040010000 0x120040010200 0x200 0x120200000000 0x120340000000 0x140000000 0x120040015000 0x120040015018 0x18 0x120040016000 0x120040016018 0x18 0x12004001c000 0x12004001c200 0x200 0x12004001d000 0x12004001d200 0x200 0x120040022000 0x120040022018 0x18 0x120040023000 0x120040023018 0x18 ***********************5. Op in graph************************* # 本环节提取报错算子的图信息 op { name: "L2Loss" type: "L2Loss" input: "Variable:0" input: "atomic_addr_clean0_11_0:-1" attr { key: "INPUT_IS_VAR" value { list { b: true val_type: VT_LIST_BOOL } } } # 省略200行 ...... } ***********************6. Dump info************************* # 本环节中可查看dump信息,并分析数据中是否存在NaN/INF信息 /home/HwHiAiUser/tools/msaicerr/info_20220314203506/collection/dump/L2Loss.L2Loss.3.1646472651352242 input[0] NaN/INF output[0] NaN/INF ***********************7. result of single_op_test************************* # 为保证本环节顺利运行,需保证环境中有真实的device在线,并安装opp、runtime、compiler包为程序运行提供支持。 # 本环节用于获取单算子运行参数并运行。运行流程如下: # - 通过日志获取异常算子的输入shape、format等编译信息。 # - 通过dump数据获取异常算子的输入数据。 # - 获取kernel_meta目录下异常算子的.o .json信息。 # - 调用rts接口调用单算子运行。 # 若运行成功,说明整网中发生的aicore error无法单算子复现,此时重点查看4.中地址是否存在异常。 # 若运行失败,抛出错误码为runtime 0x7开头错误码,则说明aicore error问题复现。此时可使用生成的单算子脚本进行分析。 # 若抛出其他异常,可具体分析。 ======================================================================== run command: None ------------------------------------------------------------------------ - test soc: [Ascendxxxx] - test case count: 1 - success count: 0 - failed count: 1 - error count: 0 ------------------------------------------------------------------------ Soc Version: Ascendxxxx failed: [L2Loss] L2Loss_pre-static_te_l2loss_0a9b2632fc2241e91c70b5a3ed5df7a95ba5024113b21f413c84e2bbb8171102_1_test (Ascendxxxx), error msg: Failed, Case File "/home/HwHiAiUser/tools/msaicerr/ms_interface/single_op_case.py", line 230 Error trace: Traceback (most recent call last): File "/home/HwHiAiUser/tools/msaicerr/ms_interface/single_op_test_frame/ut/op_ut.py", line 856, in _run_model_run_stage self._run_kernel(run_soc_version, case_info, run_cfg) File "/home/HwHiAiUser/tools/msaicerr/ms_interface/single_op_test_frame/ut/op_ut.py", line 838, in _run_kernel tiling=case_info.tiling_data, block_dim=case_info.block_dim) File "/home/HwHiAiUser/tools/msaicerr/ms_interface/single_op_test_frame/common/ascend_tbe_op.py", line 567, in run self._execute_kernel(kernel, knl_args, block_dim) File "/home/HwHiAiUser/tools/msaicerr/ms_interface/single_op_test_frame/common/ascend_tbe_op.py", line 537, in _execute_kernel _execute_kernel() File "/home/HwHiAiUser/tools/msaicerr/ms_interface/single_op_test_frame/common/ascend_tbe_op.py", line 531, in _execute_kernel self.ascend_device.synchronize_with_stream(self._stream) File "/home/HwHiAiUser/tools/msaicerr/ms_interface/single_op_test_frame/runtime/rts_api.py", line 693, in synchronize_with_stream self.parse_error(rt_error, "rtStreamSynchronize") File "/home/HwHiAiUser/tools/msaicerr/ms_interface/single_op_test_frame/runtime/rts_api.py", line 759, in parse_error raise RuntimeError("Received invalid runtime error code:" + hex(rt_error) + extra_info) RuntimeError: Received invalid runtime error code:0x7bc87 ------------------------------------------------------------------------ Some test case failed. Please check your code or case! ======================================================================== Running single op test "python3 /home/root/tools/msaicerr/info_20220314203506/aicerror_0_20220305173051/single_op_test/te_l2loss_0a9b2632fc2241e91c70b5a3ed5df7a95ba5024113b21f413c84e2bbb8171102_1_test.py" can reprocessing.
- 若执行msaicerr工具失败: