nvapi NvAPI_GPU_GetDynamicPstatesInfoEx返回NVAPI_ERROR,为什么?

时间:2018-10-19 09:20:56

标签: windows nvapi

我不知道为什么此api返回错误,显卡类型为“ GeForce GTX 1050 Ti”

NvAPI_Status nvapiStatus = NVAPI_OK;
if ((nvapiStatus = NvAPI_Initialize()) != NVAPI_OK)
{
    return 1;
}
NvPhysicalGpuHandle handles[NVAPI_MAX_PHYSICAL_GPUS];
NvU32 count = 0;
nvapiStatus = NvAPI_EnumPhysicalGPUs(handles, &count);
NV_GPU_DYNAMIC_PSTATES_INFO_EX info{};
info.version = NV_GPU_DYNAMIC_PSTATES_INFO_EX_VER;
if (nvapiStatus == NVAPI_OK && count == 1)
{
    double dGPUUtilization = 0.0;
    nvapiStatus = NvAPI_GPU_GetDynamicPstatesInfoEx(handles[0], &info);
    if (nvapiStatus == NVAPI_OK)
    {
        if (info.utilization[0].bIsPresent)
        {
            dGPUUtilization = info.utilization[0].percentage;
        }
    }
}

1 个答案:

答案 0 :(得分:0)

我发现了一个会导致此错误的原因:没有进程在使用此图形卡