DM driver model or on non-CUDA capable GPU.\n");
else if (NVML_SUCCESS != result)
{
printf("\t\t Failed to set compute mode for device %i: %s\n", i, nvmlErrorString(result));
goto Error;
}
else
{
printf("\t Restoring device's compute mode back to '%s'\n",
convertToComputeModeString(compute_mode));
result = nvmlDeviceSetComputeMode(device, compute_mode);
if (NVML_SUCCESS != result)
{
printf("\t\t Failed to restore compute mode for device %i: %s\n", i, nvmlErrorString(result));
goto Error;
}
}
}
printf("\n");
printf("----- 温度 ----- \n");
unsigned int temperature_threshold = 100;
result = nvmlDeviceGetTemperatureThreshold(device, NVML_TEMPERATURE_THRESHOLD_SHUTDOWN, &temperature_threshold);
if (NVML_SUCCESS != result)
{
printf("device %i Failed to get NVML_TEMPERATURE_THRESHOLD_SHUTDOWN: %s\n", i, nvmlErrorString(result));
}
else
printf("截止温度: %d 摄氏度 (Temperature at which the GPU will shut down for HW protection)\n", temperature_threshold);
result = nvmlDeviceGetTemperatureThreshold(device, NVML_TEMPERATURE_THRESHOLD_SLOWDOWN, &temperature_threshold);
if (NVML_SUCCESS != result)
{
printf("device %i Failed NVML_TEMPERATURE_THRESHOLD_SLOWDOWN: %s\n", i, nvmlErrorString(result));
}
else
printf("上限温度: %d 摄氏度 (Temperature at which the GPU will begin slowdown)\n", temperature_threshold);
unsigned int temperature = 0;
result = nvmlDeviceGetTemperature(device, NVML_TEMPERATURE_GPU, &temperature);
if (NVML_SUCCESS != result)
{
printf("device %i NVML_TEMPERATURE_GPU Failed: %s\n", i, nvmlErrorString(result));
}
else
printf("当前温度: %d 摄氏度 \n", temperature);
//使用率
printf("\n");
nvmlUtilization_t utilization;
result = nvmlDeviceGetUtilizationRates(device, &utilization);
if (NVML_SUCCESS != result)
{
printf(" device %i nvmlDeviceGetUtilizationRates Failed : %s\n", i, nvmlErrorString(result));
}
else
{
printf("----- 使用率 ----- \n");
printf("GPU 使用率: %lld %% \n", utilization.gpu);
printf("显存使用率: %lld %% \n", utilization.memory);
}
//FB memory
printf("\n");
nvmlMemory_t memory;
result = nvmlDeviceGetMemoryInfo(device, &memory);
if (NVML_SUCCESS != result)
{
printf("device %i nvmlDeviceGetMemoryInfo Failed : %s\n", i, nvmlErrorString(result));
}
else
{
printf("------ FB memory ------- \n");
printf("Total installed FB memory: %lld bytes \n", memory.total);
printf("Unallocated FB memory: %lld bytes \n", memory.free);
printf("Allocated FB memory: %lld bytes \n", memory.used);
}
//BAR1 memory
printf("\n");
nvmlBAR1Memory_t bar1Memory;
result = nvmlDeviceGetBAR1MemoryInfo(device, &bar1Memory);
if (NVML_SUCCESS != result)
{
printf("device %i nvmlDeviceGetBAR1MemoryInfo Failed : %s\n", i, nvmlErrorString(result));
}
else
{
printf("------ BAR1 memory ------- \n");
printf("Total BAR1 memory: %lld bytes \n", bar1Memory.bar1Total);
printf("Unallocated BAR1 memory: %lld bytes \n", bar1Memory.bar1Free);
printf("Allocated BAR1 memory: %lld bytes \n", bar1Memory.bar1Used);
}
//Information about running |