GPU: add flag --gpu-use-nvml

This commit is contained in:
李通洲
2023-10-30 13:46:51 +08:00
parent 2e30a57889
commit 485bcbf054
7 changed files with 30 additions and 7 deletions
+1 -1
View File
@@ -17,7 +17,7 @@ Features:
* Support st version detection (Terminal, Linux)
* Support st terminal font detection (TerminalFont, Linux)
* Add option `--migrate-config <?target-file-path>`
* Support Nvidia GPU temp and cuda core count detection via nvml (GPU)
* Support Nvidia GPU temp and cuda core count detection via nvml. Use `--gpu-use-nvml` to enable it (GPU)
* Try supporting Wifi authentication type detection in macOS Sonoma. Please file a feature request if you get `to be supported (num)` with result of `/System/Library/PrivateFrameworks/Apple80211.framework/Resources/airport -I | grep auth` (Wifi, macOS)
Bugfixes:
+5
View File
@@ -1130,6 +1130,11 @@
"type": "boolean",
"default": false
},
"useNvml": {
"description": "Use nvml (NVIDIA Management Library) to detect more detailed GPU information (memory usage, CUDA core count, etc)",
"type": "boolean",
"default": false
},
"forceVulkan": {
"title": "Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`",
"type": "boolean",
+1
View File
@@ -148,6 +148,7 @@ Module specific options:
--cpu-freq-ndigits <num>: Set the number of digits to keep after the decimal point when printing CPU frequency. Default is 2
--cpuusage-separate <?value>: Display CPU usage per CPU logical core, instead of an average result. Default is false
--gpu-temp <?value>: Detect and display GPU temperature if supported. Default is false
--gpu-use-nvml <?value>: Use nvml (NVIDIA Management Library) to detect more detailed GPU information (memory usage, CUDA core count, etc). Default is false
--gpu-force-vulkan <?value>: Force using vulkan to detect GPUs, which support video memory usage detection with `--allow-slow-operations`. Default is false
--gpu-hide-type <?value>: Specify the type of GPUs should not be printed. Must be `integrated`, `discrete` or `none`. Default is none
--battery-temp <?value>: Detect and display Battery temperature if supported. Default is false
+3 -3
View File
@@ -242,15 +242,15 @@ static void pciHandleDevice(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
gpu->coreCount = FF_GPU_CORE_COUNT_UNSET;
gpu->temperature = FF_GPU_TEMP_UNSET;
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || instance.config.general.allowSlowOperations))
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || options->useNvml))
{
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 = options->temp ? &gpu->temperature : NULL,
.memory = instance.config.general.allowSlowOperations ? &gpu->dedicated : NULL,
.coreCount = instance.config.general.allowSlowOperations ? (uint32_t*) &gpu->coreCount : NULL,
.memory = options->useNvml ? &gpu->dedicated : NULL,
.coreCount = options->useNvml ? (uint32_t*) &gpu->coreCount : NULL,
});
if (gpu->dedicated.total != FF_GPU_VMEM_SIZE_UNSET)
+3 -3
View File
@@ -85,7 +85,7 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
}
}
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || instance.config.general.allowSlowOperations))
if (gpu->vendor.chars == FF_GPU_VENDOR_NAME_NVIDIA && (options->temp || options->useNvml))
{
uint32_t vendorId, deviceId, subSystemId;
// See: https://download.nvidia.com/XFree86/Linux-x86_64/545.23.06/README/supportedchips.html
@@ -97,8 +97,8 @@ const char* ffDetectGPUImpl(FF_MAYBE_UNUSED const FFGPUOptions* options, FFlist*
.pciSubSystemId = subSystemId,
}, (FFGpuNvidiaResult) {
.temp = options->temp ? &gpu->temperature : NULL,
.memory = instance.config.general.allowSlowOperations ? &gpu->dedicated : NULL,
.coreCount = instance.config.general.allowSlowOperations ? (uint32_t*) &gpu->coreCount : NULL,
.memory = options->useNvml ? &gpu->dedicated : NULL,
.coreCount = options->useNvml ? (uint32_t*) &gpu->coreCount : NULL,
});
}
}
+16
View File
@@ -130,6 +130,12 @@ bool ffParseGPUCommandOptions(FFGPUOptions* options, const char* key, const char
if (ffOptionParseModuleArgs(key, subKey, value, &options->moduleArgs))
return true;
if (ffStrEqualsIgnCase(subKey, "use-nvml"))
{
options->useNvml = ffOptionParseBoolean(value);
return true;
}
if (ffStrEqualsIgnCase(subKey, "force-vulkan"))
{
options->forceVulkan = ffOptionParseBoolean(value);
@@ -174,6 +180,12 @@ void ffParseGPUJsonObject(FFGPUOptions* options, yyjson_val* module)
continue;
}
if (ffStrEqualsIgnCase(key, "useNvml"))
{
options->useNvml = yyjson_get_bool(val);
continue;
}
if (ffStrEqualsIgnCase(key, "forceVulkan"))
{
options->forceVulkan = yyjson_get_bool(val);
@@ -207,6 +219,9 @@ void ffGenerateGPUJsonConfig(FFGPUOptions* options, yyjson_mut_doc* doc, yyjson_
ffJsonConfigGenerateModuleArgsConfig(doc, module, &defaultOptions.moduleArgs, &options->moduleArgs);
if (options->useNvml != defaultOptions.useNvml)
yyjson_mut_obj_add_bool(doc, module, "useNvml", options->useNvml);
if (options->forceVulkan != defaultOptions.forceVulkan)
yyjson_mut_obj_add_bool(doc, module, "forceVulkan", options->forceVulkan);
@@ -330,6 +345,7 @@ void ffInitGPUOptions(FFGPUOptions* options)
);
ffOptionInitModuleArg(&options->moduleArgs);
options->useNvml = false;
options->forceVulkan = false;
options->temp = false;
options->hideType = FF_GPU_TYPE_UNKNOWN;
+1
View File
@@ -18,5 +18,6 @@ typedef struct FFGPUOptions
FFGPUType hideType;
bool temp;
bool useNvml;
bool forceVulkan;
} FFGPUOptions;