GPU: guard nvml related code behind --allow-slow-operations

This commit is contained in:
李通洲
2023-10-28 17:23:49 +08:00
parent 38d5791d57
commit 799628c083
2 changed files with 13 additions and 12 deletions
+11 -10
View File
@@ -242,24 +242,25 @@ static void pciHandleDevice(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->temperature = FF_GPU_TEMP_UNSET;
#ifdef __linux__
if(options->temp)
pciDetectTemp(gpu, device);
#endif
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA)
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || instance.config.general.allowSlowOperations))
{
char pciDeviceId[32];
snprintf(pciDeviceId, sizeof(pciDeviceId) - 1, "%04x:%02x:%02x.%d", device->domain, device->bus, device->dev, device->func);
ffDetectNvidiaGpuInfo((FFGpuNvidiaCondition) { .pciBusId = pciDeviceId }, (FFGpuNvidiaResult) {
.temp = gpu->temperature != gpu->temperature ? &gpu->temperature : NULL,
.memory = &gpu->dedicated,
.coreCount = (uint32_t*) &gpu->coreCount,
.temp = options->temp ? &gpu->temperature : NULL,
.memory = instance.config.general.allowSlowOperations ? &gpu->dedicated : NULL,
.coreCount = instance.config.general.allowSlowOperations ? (uint32_t*) &gpu->coreCount : NULL,
});
gpu->type = gpu->dedicated.total > 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
if (gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET)
gpu->type = gpu->dedicated.total > 1024 * 1024 * 1024 ? FF_GPU_TYPE_DISCRETE : FF_GPU_TYPE_INTEGRATED;
}
#ifdef __linux__
if(options->temp && gpu->temperature != gpu->temperature)
pciDetectTemp(gpu, device);
#endif
}
jmp_buf pciInitJmpBuf;
+2 -2
View File
@@ -97,8 +97,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
.pciSubSystemId = subSystemId,
}, (FFGpuNvidiaResult) {
.temp = options->temp ? &gpu->temperature : NULL,
.memory = &gpu->dedicated,
.coreCount = (uint32_t*) &gpu->coreCount,
.memory = instance.config.general.allowSlowOperations ? &gpu->dedicated : NULL,
.coreCount = instance.config.general.allowSlowOperations ? (uint32_t*) &gpu->coreCount : NULL,
});
}
}