Exporting Profile Data
Before exporting profile data, finish profile data parsing. For details, see Parsing Profile Data. Start profile data export as follows:
- Log in as the running user to the development environment where the CANN Toolkit package and ops operator package are located.
- Switch to the directory where the msprof.py script is located.
${INSTALL_DIR}/tools/profiler/profiler_tool/analysis/msprof. Replace ${INSTALL_DIR} with the actual CANN component directory. If the Ascend-CANN-Toolkit package is installed as the root user, the CANN component directory is /usr/local/Ascend/ascend-toolkit/latest.
- Export profile data. The timeline, db, and summary files can be exported. The command syntax is as follows:
- Exporting timeline data and .db files
python3 msprof.py export timeline -dir <dir> [-reports <reports_sample_config.json>] [--iteration-id <iteration_id>] [--model-id <model-id>] [--iteration-count <iteration_count>] [--clear]
Example: python3 msprof.py export timeline -dir /home/HwHiAiUser/profiler_data/PROF_XXX
- Exporting summary data and .db files
python3 msprof.py export summary -dir <dir> [--iteration-id <iteration_id>] [--model-id <model-id>] [--iteration-count <iteration_count>] [--format <export_format>] [--clear]
Example: python3 msprof.py export summary -dir /home/HwHiAiUser/profiler_data/PROF_XXX
- Exporting .db files
python3 msprof.py export db -dir <dir>
Generate a .db file (msprof_timestamp.db) that summarizes all profile data.
Example: python3 msprof.py export db -dir /home/HwHiAiUser/profiler_data/PROF_XXX
Table 1 Command-line options Option
Description
Required/Optional
-dir or --collection-dir
Directory of collected profile data. The value must be PROF_XXX or the parent directory of PROF_XXX, for example,
/home/HwHiAiUser/profiler_data/PROF_XXX
Required
-reports
After the custom reports_sample_config.json configuration file is passed, the corresponding profile data files are exported based on the range specified in the configuration file. This parameter is implemented the same way as msprof --reports. For details, see Parameter Usage of --reports.
Optional
--iteration-id
Iteration ID. The value must be a positive integer. The default value is 1. This option and --model-id must be configured at the same time.
- For the Atlas A2 Training Series Product/Atlas 800I A2 Inference Product, if --model-id is set to 4294967295, this option specifies the iteration ID for step-level profiling. The iteration ID is incremented by 1 each time a step is executed. Only profile data of the MindSpore framework (version 2.3 or later) can be parsed.
- For the Atlas A3 Training Series Product, if --model-id is set to 4294967295, this option specifies the iteration ID for step-level profiling. The iteration ID is incremented by 1 each time a step is executed. Only profile data of the MindSpore framework (version 2.3 or later) can be parsed.
- If --model-id is set to other values, this option specifies the iteration ID for graph-based statistics collection. (The iteration ID is incremented by 1 each time a graph is executed. When a script is compiled into multiple graphs, the iteration ID is different from the step ID at the script layer.)
Optional
--model-id
Model ID. The value must be a positive integer. This option and --iteration-id must be configured at the same time.
- For the Atlas A2 Training Series Product/Atlas 800I A2 Inference Product, --model-id can be set to 4294967295, which specifies the step mode. That is, the value of --iteration-id specifies parsing by step. Only profile data of the MindSpore framework (version 2.3 or later) can be parsed.
- For the Atlas A3 Training Series Product, --model-id can be set to 4294967295, which specifies the step mode. That is, the value of --iteration-id specifies parsing by step. Only profile data of the MindSpore framework (version 2.3 or later) can be parsed.
- If --model-id is set to other values, the graph mode is used. That is, the value of --iteration-id specifies parsing by graph.
Optional
--iteration-count
Number of consecutive steps for which data will be exported. The value is an integer ranging from 1 to 5. The value of --iteration-id is the start step. For example, if --iteration-count is set to 3 and --iteration-id is set to 1, data for steps 1, 2, and 3 will be exported.
Optional
--format
File format, either csv (default) or json.
This option is supported only when the summary parameter is configured.
The following uses summary files in .csv format as examples.
Optional
--clear
Data clearance mode. After this option is enabled, the sqlite directory in PROF_XXX/device_{id} is deleted after profile data is exported, so as to save storage space. When this parameter is configured, the data clearance mode is enabled. This parameter is not configured by default.
Optional
-h or --help
Help information.
Optional
Note 1: all profile data is exported by default.
Note 2: In single-operator scenarios and scenarios where only Profiling the Ascend AI Processor System is involved, --iteration-id and --model-id are not supported.
- Exporting timeline data and .db files
- After the preceding command is executed, find the mindstudio_profiler_output directory and the msprof_*.db file in the PROF_XXX directory under collection-dir.
The following shows the directory structure of the generated profile data:
- Single-process collection
1 2 3 4 5 6 7 8 9 10 11 12 13 14
└── PROF_XXX ├── device_0 │ └── data ├── device_1 │ └── data ├── host │ └── data ├── msprof_*.db └── mindstudio_profiler_output ├── msprof_{timestamp}.json ├── step_trace_{timestamp}.json ├── xx_*.csv ... └── README.txt
- Multi-process collection
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
└── PROF_XXX1 ├── device_0 │ └── data ├── host │ └── data ├── msprof_*.db └── mindstudio_profiler_output ├── msprof_{timestamp}.json ├── step_trace_{timestamp}.json ├── xx_*.csv ... └── README.txt └── PROF_XXX2 ├── device_1 │ └── data ├── host │ └── data ├── msprof_*.db └── mindstudio_profiler_output ├── msprof_{timestamp}.json ├── step_trace_{timestamp}.json ├── xx_*.csv ... └── README.txt
- In multi-device setups, if single-process collection is started, only one PROF_XXX directory is generated. If multi-process collection is started, multiple PROF_XXX directories are generated. In addition, the device directory is generated in the PROF_XXX directory. The number of device directories generated in each PROF_XXX directory is related to the actual user operations and does not affect profile data analysis.
- For details about profile data, see Profile Data File References.
- The files in the mindstudio_profiler_output directory are generated based on the actual collected profile data. If the necessary profile data file is absent, the corresponding timeline and summary data will be unavailable.
- You can run the export command to directly export summary reports from the profile data parsing result. Even the profile data has not been parsed, the export command can parse the profile data and export the reports.
- For a msprof collection process that is forcibly interrupted, the tool saves the collected raw profile data. You can also run export to parse and export the data.
- Single-process collection