How to export SoC Metrics from nsight system report to .csv file?

I have a nsight system report that has SoC Metrics in it:


, and I want to export SoC Metrics to a text file. I used the command “nsys stats --format csv report.nsys-rep > report.csv” to export the report to a csv file, but I realized that there is no SoC Metrics in it. How can I export the SoC Metrics of this report?

I believe that unfortunately those metrics are only currently exported to the SQLite format. @jkreibich to confirm.

That is correct. The nsys stats command is used to run reports (you can get a list with --help-reports). However, there are no existing reports that display the SoC Metric data.

The simple answer: dump the SQLite file

Most of the SoC data can be found in two tables: TARGET_INFO_SOC_METRICS provides a list of metrics and their ID values. The specific list of available metrics depends on the GPU and drivers, .etc., so it is a dynamic list. The SOC_METRICS table has the actual metrics values.

If you just want to dump this data to a CSV file, export your .nsys-rep file to an SQLite file (by running any nsys stats command, or with the command nsys export --type=sqlite <report.nsys-rep>). Once the SQLite file is available, you can run a CLI command such as:

$ sqlite3 -header -csv report.sqlite \
   "SELECT * FROM TARGET_INFO_SOC_METRICS JOIN SOC_METRICS USING (metricId)"

This command runs the sqlite3 command shell, sets the output to csv with headers (only one dash for those) and executes the given query. It will output one metric per row, so you’ll need to group a set of rows to get a single set of SoC Metrics.

The more complex answer: write a stats report or recipe

Another option is to write your own stats report and/or recipe (see nsys recipe). Recipes are only available on Linux systems, however. Stats reports and recipes are pre-pacakged analysis reports that are written in Python. Stats usually use SQL queries to do their calculations, while Recipes use Pandas DataFrames.

If you package the query up into a stats report, it becomes available to the CLI and the GUI. This is a higher barrier, in terms of creating the report, but will make accessing and using data much easier, especially if you need to share with coworkers. I can help a little with that process.

Recipes allow nearly infinite analysis, and are a good path if you’re comfortable with Python and Pandas. There is a GTC class that covered how to write your own.

In both cases, it is usually easier to take an existing report and modify it. You can find stats reports in <nsys_install_dir>/reports. Alas, there is very little documentation.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.