I was trying to get the board serial number but the functions always return a array filled with 0.
NV_PHYSICAL_GPUS_V1 nvPhysicalGPUs = { 0 };
nvPhysicalGPUs.version = NV_PHYSICAL_GPUS_VER1;
status = NvAPI_SYS_GetPhysicalGPUs(&nvPhysicalGPUs);
if (status != NVAPI_OK)
{
NvAPI_GetErrorMessage(status, szError);
printf("\nNvAPI_SYS_GetPhysicalGPUs() failed. The Error code is: %s", szError);
return -1;
}
for (NvU32 i = 0; i < nvPhysicalGPUs.gpuHandleCount; i++)
{
printf("\nPhysical_GPUHandle[%d]:0x%p | AdapterType = %d", i, nvPhysicalGPUs.gpuHandleData[i].hPhysicalGpu,
nvPhysicalGPUs.gpuHandleData[i].adapterType);
_NV_BOARD_INFO info = { 0 };
info.version = NV_BOARD_INFO_VER1;
NvPhysicalGpuHandle gpu = nvPhysicalGPUs.gpuHandleData[i].hPhysicalGpu;
auto res = NvAPI_GPU_GetBoardInfo(gpu, &info);
if (res != NVAPI_OK) {
cout << "Fail: " << res << endl;
}
cout << endl;
string serialNumber;
for (i = 0; i < 16; i++) {
serialNumber += std::to_string(info.BoardNum[i]);
}
cout << serialNumber << endl;
}