NVPW metric enumeration gives segfault

System setup:

  • HW: RTX 2070 (TU106)
  • SW: Ubuntu 16.04, CUDA 10, Driver 410.48, CUpti 10.1

Sanity check:

  • Both userrange_profiling and autorange_profiling in CUpti samples run properly on my system.

Issue:
I used the following code to enumerate available metrics on the system:

NVPW_MetricsContext_GetMetricNames_Begin_Params enumMetricParams = 
                              {NVPW_MetricsContext_GetMetricNames_Begin_Params_STRUCT_SIZE};
NVPW_MetricsContext_GetMetricNames_Begin(&enumMetricParams);

However, I got a segmentation fault from running this code snippet. GDB “info stack” gives me this information:

#0 0x00007ffff5c5df97 in NVPW_MetricsContext_GetMetricNames_Begin ()
from …/…/lib/x64/libnvperf_host.so


Any help would be greatly appreciated! Thanks in advance!

Hello Serinatan,

It appears you are not setting the input parameters required for the API, these are MetricsContext APIs and requires MetricsContext to be set as input parameter to enumerate.
Although nvperf_host.h headers misses to list it as “[in]” in the comment section.

For example:

/* Create metrics context */
const char* chipName = "tu106"
NVPW_CUDA_MetricsContext_Create_Params metricsContextCreateParams ={ NVPW_CUDA_MetricsContext_Create_Params_STRUCT_SIZE };
metricsContextCreateParams.pChipName = chipName;
NVPW_CUDA_MetricsContext_Create(&metricsContextCreateParams);

/* Get metric names */
NVPW_MetricsContext_GetMetricNames_Begin_Params enumMetricParams = 
                              {NVPW_MetricsContext_GetMetricNames_Begin_Params_STRUCT_SIZE};
enumMetricParams.pMetricsContext = metricsContextCreateParams.pMetricsContext;
NVPW_MetricsContext_GetMetricNames_Begin(&enumMetricParams);

In your cupti package refer code
samples\extensions\src\profilerhost_util\List.cpp for metric enumeration.
samples\extensions\src\profilerhost_util\Metric.cpp for metric configuration.
samples\extensions\src\profilerhost_util\Eval.cpp for metric evaluation.

Hope this helps!

Awesome, thank you very much for your prompt reply! It worked! Thanks for pointing out the sample code path too!