Single-Operator Profiling
This section describes how to use a single-operator to call an executable file for operator Profiling. You can analyze the time consumption and performance of the operator based on the performance analysis result displayed in the CLI.
The Add operator is used as an example to describe how to collect profile data of a single-operator.
Prerequisites
- Check whether the ada process in the operating environment starts normally as the HwHiAiUser user (running user).
ps -ef | grep ada
If the following information is displayed, the ada process starts properly.
HwHiAiU+ 9150 1 4 00:20 ? 00:00:33 ./ada HwHiAiU+ 15466 28262 0 00:31 pts/12 00:00:00 grep ada
- Set the path of the dynamic library the app depends on in the /etc/ld.so.conf file in the operating environment as the root user and make the setting take effect.
- Add the path of the dynamic library the app executable file depends on to the end of the /etc/ld.so.conf file as the root user.
- Standard-form Ascend EP:
/home/HwHiAiUser/Ascend/ascend-toolkit/latest/acllib/lib64 /usr/local/Ascend/driver/lib64
- For Ascend RC, the modifications on the board environment are as follows:
/home/HwHiAiUser/Ascend/acllib/lib64 /usr/lib64
- Standard-form Ascend EP:
- Run the :wq command to save the modifications and exit.
- Run the ldconfig command for the settings to take effect.
- Add the path of the dynamic library the app executable file depends on to the end of the /etc/ld.so.conf file as the root user.
Procedure
- As the HwHiAiUser user (running user), copy the out folder generated after building the Add operator described in Verifying the Execution of the Add Operator (containing the executable file, model file, and test data) to any directory in the operating environment, and grant the execute permission on the execute_add_op file.
The following assumes that the executable file, model file, and test data generated after the build of the Add operator verification program have been stored in the $HOME/HIAI_PROJECTS/run_add/out directory.
- Run the following command as the HwHiAiUser user (Toolkit installation user) in the development environment to go to the directory of the hiprof.pyc script.
cd /home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/tools/profiler/profiler_tool/analysis/command/
Replace /home/HwHiAiUser/Ascend/ascend-toolkit/latest with the actual Toolkit installation path.
- Set the environment variable.
export LD_LIBRARY_PATH=/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/lib64:${LD_LIBRARY_PATH}
- Collect profile data during the execution of the Add operator:
python3.7.5 hiprof.pyc --ip_address=xx.xx.xx.xx --adc_dir=/home/HwHiAiUser/Ascend/ascend-toolkit/latest/toolkit/tools/ide_daemon/bin --app=/home/HwHiAiUser/HIAI_PROJECTS/run_add/out/execute_add_op --result_dir=/home/HwHiAiUser/tools/out_add/ --profiling_options=op_trace --ai_core_metrics=aicoreMetricsAll
- ip_address: IP address of the operating environment, used to communicate with the development environment.
- app: absolute path (including the file name) of the executable file in the operating environment for verifying the single-operator.
- result_dir: profiling result path in the development environment. The path must exist and is readable and writeable by the HwHiAiUser user.
- ai_core_metrics: AI Core profiling metrics. For details, see Profiling Tool Instructions.
- After command execution, view the profiling result in the CLI. For details, see Profiling Tool Instructions.