工具启动
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
- 以AddCustom算子为例,算子编译后可获取NPU侧可执行文件add_custom_npu。
- 输入如下命令,使用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脚本
- 完成了PyTorch框架的适配插件开发后,即可实现从PyTorch框架调用Ascend C自定义算子,可以通过自定义python脚本test_ops_custom.py调用算子。
- 输入如下命令,使用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)
父主题: 快速入门