When the profile data collected using the Ascend PyTorch Profiler APIs is large, using the on_trace_ready API in the current environment for automatic parsing may cause excessive resource consumption and result in lags. In this case, you can cancel the on_trace_ready API, use the ASCEND_WORK_PATH environment variable to set the flush directory (for example, export ASCEND_WORK_PATH=xx/xx), and use the following method to parse the collected profile data in offline mode:
1 2 3 4 | from torch_npu.profiler.profiler import analyse if __name__ == "__main__": analyse(profiler_path="./result_data", max_process_number=max_process_number, export_type=export_type) |
Parameter |
Description |
Optional/Required |
|---|---|---|
profiler_path |
PyTorch profile data path. The path can contain only letters, digits, underscores (_), and hyphens (-). Soft links are not supported. This specified path stores the PyTorch profile data directory {worker_name}_{timestamp}_ascend_pt. |
Required |
max_process_number |
Maximum number of offline analysis processes. The value ranges from 1 to the number of CPU cores. The default value is half of the number of CPU cores. If the value of this parameter exceeds the number of available CPU cores in the environment, the system will automatically utilize all available CPU cores. If this parameter is set to an invalid value, half of the default number of CPU cores is used. |
Optional |
export_type |
Format of the exported profile data result file. The value is of the list type. Possible values are as follows:
If this parameter is set to an invalid value or is not configured, the export_type field in the profiler_info.json file is read to determine the export format. For details about the parsing results, see MindSpore & PyTorch Profile Data File References. |
Optional |
python3 {file_name}.py
For details about profile data result files, see MindSpore & PyTorch Profile Data File References.
For details about how to visualize and analyze the parsed profile data files, see MindStudio Insight User Guide.
You can use the msprof-analyze to analyze the profile data.