show_kernel_debug_data

In the static graph scenario, all operators of the entire graph are offloaded to the NPU for execution. The single-operator debugging information (through the printf API) on the kernel can be obtained only after the model execution is complete. This tool provides the offline parsing capability to help users obtain and parse the debugging information (parse the .bin file into a readable format).

show_kernel_debug_data can be called by multiple users concurrently. However, users need to specify different flushing paths. Otherwise, the flushed content may be overwritten.

Applicability

Product

Supported

Atlas A3 training products / Atlas A3 inference products

Atlas A2 training products / Atlas A2 inference products

Atlas 200I/500 A2 inference products

Atlas inference products

Atlas training products

x

Tool Installation

  1. Install the tool.

    The tool is released with the CANN package. (For details about how to install the CANN package, see Environment Setup). The default path is ${INSTALL_DIR}/tools/show_kernel_debug_data. Replace ${INSTALL_DIR} with the CANN component directory. For example, if the installation is performed by the root user, the default file storage path is /usr/local/Ascend/cann.

  2. Set environment variables.
    • Install the Ascend-CANN-Toolkit package as the root user:
      source /usr/local/Ascend/cann/set_env.sh
    • Install the Ascend-CANN-Toolkit package as a non-root user:
      source ${HOME}/Ascend/cann/set_env.sh
  3. Check whether the tool is successfully installed.
    Run the following command. If --help or -h is displayed, the tool environment is normal and the functions are normal.
    show_kernel_debug_data -h

How to Use

  • Command line
    show_kernel_debug_data <bin_file_path> [<output_path>]

    Parameter

    Required

    Description

    <bin_file_path>

    Yes

    Path of the .bin file for flushing kernel debugging information to the disk, for example, /input/dump_workspace.bin.

    <output_path>

    No

    Path for saving the parsing result, for example, /output_dir. The default path is the path where the current command is executed.

  • API
    Table 1 Description of the show_kernel_debug_data API

    Prototype

    def show_kernel_debug_data(bin_file_path: str, output_path: str = './') -> None

    Function

    Obtains the debugging information on the kernel and parses the information into a readable file.

    Input Parameter

    bin_file_path

    Path of the .bin file for flushing kernel debugging information to the disk. The value is of the string type.

    output_path

    Path for saving the parsed result. The value is of the string type. The default path is the path where the current API calling script is located.

    Output Parameter

    N/A

    -

    Returns

    N/A

    -

    Constraints

    None

    Example

    1
    2
    from show_kernel_debug_data import show_kernel_debug_data
    show_kernel_debug_data(./input/dump_workspace.bin)
    

Result

The directory structure of the parsed result file is as follows:

├ ${output_path}
├── PARSER_${timestamp}           // ${timestamp} indicates the timestamp.
│   ├── parser.log              // Tool parsing log, including the routine process on the kernel and printf information.