Why does cuptiActivityEnable(CUPTI_ACTIVITY_KIND_UNIFIED_MEMORY_COUNTER) returns CUPTI_ERROR_NOT_READY?

Hi:
I am trying to use the activity APIs to gather the GPU page faults under unified memory. So, I called

cuptiActivityEnable(CUPTI_ACTIVITY_KIND_UNIFIED_MEMORY_COUNTER)

to enable the unified memory counter. However, it returns CUPTI_ERROR_NOT_READY. When I tried to call

cuptiActivityEnableContext(context, CUPTI_ACTIVITY_KIND_UNIFIED_MEMORY_COUNTER)

But, I got CUPTI_ERROR_INVALID_KIND.

Does anyone can provide any hint about how to collect the unified memory counter? Thank you.

Unified memory counter/s need to be configured before enabling the activity CUPTI_ACTIVITY_KIND_UNIFIED_MEMORY_COUNTER. Did you follow this order?

Activity kind CUPTI_ACTIVITY_KIND_UNIFIED_MEMORY_COUNTER is not supported at the context level, that’s reason cuptiActivityEnableContext throws error CUPTI_ERROR_INVALID_KIND.

Refer CUPTI sample unified_memory for the use case.

Hi mjain:
This is the exact cause. Thank you for your reply. I was a little misled by the document (https://docs.nvidia.com/cupti/Cupti/modules.html#group__CUPTI__ACTIVITY__API_1g348cf81393b39ab2f89604aaaa8defc2) where cuptiActivityEnable does not return CUPTI_ERROR_NOT_READY. It is not easy to figure out the order between configuration and enabling.

Good to know that it works. We’d improve the documentation to make it clear. Thanks!