A Python script to convert the output of NVIDIA Nsight Systems (in SQLite format) to JSON in Google Chrome Trace Event Format for more customizable visualization and analysis. To view the resulting json file, goto chrome://tracing
in Google Chrome or use Perfetto.
Inspired and adapted from nvprof2json.
The SQLite schema used by Nsight Systems is documented here.
If you have a '.qdrep' file, you can convert it first to SQLite format through Nsight Systems UI or CLI.
To extract kernel activities and NVTX annotated regions (e.g. torch.cuda.nvtx.range):
python3 nsys2json.py <nsys_sqlite_file> -o <output_json>
To filter out only kernel activities or NVTX annotated regions, use:
-activity-type {kernel,nvtx}
To filter NVTX regions based on name, use:
--nvtx-event-prefix <prefix>
To apply custom coloring scheme to NVTX regions, use:
--nvtx-color-scheme <dict_mapping_regex_to_chrome_colors>
e.g.,
--nvtx-color-scheme '{"comm": "thread_state_iowait", "Layer .* compute": "thread_state_running"}
For the list of available colors, see here.
- This script assumes each process in the profile only executes kernel on one GPU. Process id is used to match NVTX regions to the corresponding device. Changes to process and thread naming scheme in the JSON file are needed if this assumption is violated.