Error using GetAllClockFrequencies

Hello,

My program works fine for GPU Name and Temperature.
Now I try to retrieve my GPU’s Clocks by using NvAPI_GPU_GetAllClockFrequencies.
My Code looks like this:

NvAPI_Status status = NVAPI_OK;

NV_GPU_CLOCK_FREQUENCIES clocks;
NvU32 frequency;
status = NvAPI_GPU_GetAllClockFrequencies(phys, &clocks);

At this line I get the Error status NVAPI_INCOMPATIBLE_STRUCT_VERSION (-9).

  1. Why?
  2. How can I repair it?
    I tried to work through the documentation but I couldn’t find anything that helped.
    Thanks for your help.

This was finally working for my problem.
Before calling the function GetAllClockFrequencies, the correct version of clocks muste be set manually:

clocks.version = NV_GPU_CLOCK_FREQUENCIES_VER_2;

Now the program shuld work as intended.