昇腾社区首页
中文
注册

AI Core Error问题定位与分析流程

使用场景概述

执行业务时,若日志文件或屏幕打印信息中包含如下AI Core Error报错,此时,需要先使用故障信息收集工具asys收集故障信息,再配合使用AI Core Error分析工具msaicerr快速定位AI Core error问题的关键原因,提升开发者对AI Core Error的排查效率。

# 报错示例
there is an xx aicore error

# 或报错示例
there is an xx aivec error

使用约束

  1. 该工具仅支持本地分析使用,即部署该工具的环境应该和日志所在环境为同一环境(运行环境)。
  2. 该工具依赖python3.7.5或以上版本,在安装该工具的环境中需提前安装python。
  3. 该工具不支持在RC模式下使用:
  4. 该工具暂不支持分析以下算子的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。

使用指导

  1. 以运行用户登录CANN运行环境。
  2. 使用故障信息收集工具asys收集故障信息
    • 推理场景,执行asys launch命令,执行业务复跑+故障信息收集
      asys launch --task="sh ../app_run.sh" [--output="path"]

      task表示要复跑的任务,output表示收集信息所存放的目录,详细参数说明及约束请参见业务复跑+故障信息收集

      注意:推理场景下,需先使用asys launch命令复跑ATC模型转换任务,再使用重新编译的模型、使用asys launch命令复跑推理业务。另外,还需将模型转换时收集的维测信息与推理时收集的维测信息放到一个目录下,例如:$HOME/asys_output。

    • 训练场景,执行asys collect命令,收集故障信息
      asys collect [--output="path"]

      output表示收集信息所存放的目录,详细参数说明及约束请参见故障信息收集

  3. 使用AI Core Error分析工具msaicerr快速定位AI Core Error问题的关键原因

    进入“Toolkit包安装路径{$install_path}/tools/msaicerr”目录,根据2中获取到故障信息,执行以下命令提取AI Core Error问题相关的关键信息。

    python3 msaicerr.py -p $HOME/asys_output
    • 2中获取到故障信息中,请提前检查dfx/data-dump目录下是否存在dump文件、检查dfx/ops目录下是否存在算子编译信息(算子编译*.o和*.json文件)、检查dfx/log/cann目录下是否日志文件,若不存在,则无法使用msaicerr工具提取AI Core Error信息。
    • 如果执行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,查看具体参数的含义。

    以上命令中的“$HOME/asys_output”目录需根据2中存放的目录替换,执行命令成功后,在执行命令的同级目录下生成“info_{时间戳}/{aicore_{number}_{时间戳}/info.txt”文件(示例请参见AI Core Error问题分析结果文件示例)以及异常算子测试文件test_single_op.py(该文件仅在有异常算子时才存在)。

    用户可以直接通过info.txt文件进行问题分析和定位,重点关注Root cause conclusion处包含的关键信息,如下表所示。还可以执行python3 test_single_op.py进一步查看异常算子执行过程中的报错信息,便于分析异常算子的报错原因。

    表1 Root cause conclusion处包含的关键信息

    关键信息

    问题原因

    处理方法

    Golden Op run error on your environment.

    环境异常

    系统环境/硬件问题

    Single op test aicore error

    单算子实现异常或编译过程异常

    单算子运行报错

    Atomic accumulation exception

    由于精度问题导致溢出

    atomic add精度溢出

    The addr of input/output is used but not alloc

    算子输入输出数据地址异常

    算子输入参数异常

    The args of op is diffrerent before and after excute

    算子输入输出参数异常

    Dump数据失败

AI Core Error问题分析结果文件示例

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.