Skip to content

Commit 3dd3150

Browse files
committed
refactor: gpustack update gpu name for nvidia gpu
1 parent b6943fc commit 3dd3150

File tree

4 files changed

+15
-1
lines changed

4 files changed

+15
-1
lines changed

src/detection/gpu/gpu_driver_specific.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ typedef struct FFGpuDriverResult
3939
{
4040
uint8_t* index;
4141
FFstrbuf* uuid;
42+
FFstrbuf* name;
4243
double* temp;
4344
FFGPUMemory* memory;
4445
uint32_t* coreCount;

src/detection/gpu/gpu_linux.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ static const char* detectPci(const FFGPUOptions* options, FFlist* gpus, FFstrbuf
297297
.frequency = options->driverSpecific ? &gpu->frequency : NULL,
298298
.coreUtilizationRate = &gpu->coreUtilizationRate,
299299
.uuid = &gpu->uuid,
300+
.name = &gpu->name,
300301
},
301302
"libnvidia-ml.so");
302303
}

src/detection/gpu/gpu_nvidia.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ struct FFNvmlData {
1717
FF_LIBRARY_SYMBOL(nvmlDeviceGetUtilizationRates)
1818
FF_LIBRARY_SYMBOL(nvmlDeviceGetUUID)
1919
FF_LIBRARY_SYMBOL(nvmlDeviceGetIndex)
20+
FF_LIBRARY_SYMBOL(nvmlDeviceGetName)
2021

2122
bool inited;
2223
} nvmlData;
@@ -44,6 +45,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
4445
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetUtilizationRates)
4546
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetUUID)
4647
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetIndex)
48+
FF_LIBRARY_LOAD_SYMBOL_VAR_MESSAGE(libnvml, nvmlData, nvmlDeviceGetName)
4749

4850
if (ffnvmlInit_v2() != NVML_SUCCESS)
4951
{
@@ -168,6 +170,13 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
168170
ffStrbufAppendS(result.uuid, uuid);
169171
}
170172

173+
if (result.name)
174+
{
175+
char name[NVML_DEVICE_NAME_V2_BUFFER_SIZE];
176+
if (nvmlData.ffnvmlDeviceGetName(device, name, sizeof(name)) == NVML_SUCCESS)
177+
ffStrbufSetS(result.name, name);
178+
}
179+
171180
return NULL;
172181

173182
#else

src/detection/gpu/nvml.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#define NVML_DEVICE_PCI_BUS_ID_BUFFER_SIZE 32
99
#define NVML_DEVICE_PCI_BUS_ID_BUFFER_V2_SIZE 16
1010
#define NVML_DEVICE_UUID_V2_BUFFER_SIZE 96
11+
#define NVML_DEVICE_NAME_V2_BUFFER_SIZE 96
1112

1213
typedef enum { NVML_SUCCESS = 0 } nvmlReturn_t;
1314
typedef struct nvmlDevice_t* nvmlDevice_t;
@@ -150,4 +151,6 @@ extern nvmlReturn_t nvmlDeviceGetUtilizationRates(nvmlDevice_t device, nvmlUtili
150151
// Retrieves the globally unique immutable UUID associated with this device, as a 5 part hexadecimal string, that augments the immutable, board serial identifier.
151152
extern nvmlReturn_t nvmlDeviceGetUUID(nvmlDevice_t device, char *uuid, unsigned int length);
152153
// Retrieves the NVML index of this device.
153-
extern nvmlReturn_t nvmlDeviceGetIndex(nvmlDevice_t device, unsigned int *index);
154+
extern nvmlReturn_t nvmlDeviceGetIndex(nvmlDevice_t device, unsigned int *index);
155+
// Retrieves the name of this device.
156+
extern nvmlReturn_t nvmlDeviceGetName(nvmlDevice_t device, char *name, unsigned int length);

0 commit comments

Comments
 (0)