昇腾社区首页
中文
注册

工具启动

msdebug工具安装在Ascend-cann-toolkit开发套件包中,工具路径为${INSTALL_DIR}/tools/msdebug/bin/msdebug。

  • ${INSTALL_DIR}请替换为CANN软件安装后文件存储路径。例如,若安装的Ascend-cann-toolkit软件包,则安装后文件存储路径为:$HOME/Ascend/ascend-toolkit/latest。
  • 若完成了环境准备章节中的环境变量配置,则无需切换目录直接执行msdebug命令。

msdebug工具支持以下两种启动方式:

若工具弹出Cannot read termcap database; using dumb terminal settings. 的提示信息,可以通过配置export TERMINFO=xx消除提示,xx为本地TERMINFO路径:
export TERMINFO=xx    //xx信息可通过infocmp -D命令查询。
  • 加载可执行文件<kernel_name>_npu
    1. 以AddCustom算子为例,算子编译后可获取NPU侧可执行文件add_custom_npu。

      基于Ascend C算子的kernel侧框架执行一键式编译运行,可生成NPU侧可执行文件<kernel_name>_npu,具体操作可参考Ascend C自定义算子开发指南中的“核函数运行验证”章节。

    2. 输入如下命令,使用msdebug工具加载可执行文件。
      $ msdebug ./add_custom_npu
      (msdebug) target create "./add_custom_npu"
      Current executable set to '${INSTALL_DIR}/projects/add_ascendc_sample/add_custom_npu' (aarch64).
      (msdebug)
      若可执行文件有其他入参,则按照如下形式传入入参:
      msdebug ./add_custom_npu parameter1 parameter2 ...
  • 加载调用算子的python脚本
    1. 完成了PyTorch框架的适配插件开发后,即可实现从PyTorch框架调用Ascend C自定义算子,可以通过自定义python脚本test_ops_custom.py调用算子。

      通过PyTorch框架进行单算子调用的场景,详细信息可参考Ascend C自定义算子开发指南中“网络中算子调用 > PyTorch框架”章节。

    2. 输入如下命令,使用msdebug工具加载python脚本。
      $ msdebug python3 test_ops_custom.py
      msdebug(MindStudio Debugger) is part of MindStudio Operator-dev Tools.
      The tool provides developers with a mechanism for debugging Ascend kernels running on actual hardware.
      This enables developers to debug Ascend kernels without being affected by potential changes brought by simulation and emulation environments.
      (msdebug) target create "./add_custom_npu"
      Current executable set to ''${INSTALL_DIR}/projects/add_ascendc_sample/add_custom_npu' (aarch64).
      (msdebug) settings set -- target.run-args  "test_ops_custom.py"
      (msdebug)