@@ -33,7 +33,7 @@ struct FFNvapiData {
33
33
bool inited ;
34
34
} nvapiData ;
35
35
36
- const char * detectMemTypeByNvapi (FFGpuDriverResult * result )
36
+ static const char * detectMemTypeByNvapi (FFGpuDriverResult * result )
37
37
{
38
38
if (!nvapiData .inited )
39
39
{
@@ -79,11 +79,14 @@ const char* detectMemTypeByNvapi(FFGpuDriverResult* result)
79
79
80
80
uint32_t gpuIndex = * result -> index ;
81
81
82
- if ((uint32_t ) gpuCount < gpuIndex )
82
+ if (gpuIndex >= (uint32_t ) gpuCount )
83
83
return "GPU index out of range" ;
84
84
85
+ // Not very sure. Need to check in multi-GPU system
86
+ NvPhysicalGpuHandle gpuHandle = handles [gpuIndex ];
87
+
85
88
NvApiGPUMemoryType memType ;
86
- if (nvapiData .ffnvapi_GPU_GetRamType (handles [ gpuIndex ] , & memType ) < 0 )
89
+ if (nvapiData .ffnvapi_GPU_GetRamType (gpuHandle , & memType ) < 0 )
87
90
return "NvAPI_GPU_GetRamType() failed" ;
88
91
89
92
switch (memType )
@@ -160,7 +163,7 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
160
163
if (cond -> type & FF_GPU_DRIVER_CONDITION_TYPE_BUS_ID )
161
164
{
162
165
char pciBusIdStr [32 ];
163
- snprintf (pciBusIdStr , ARRAY_SIZE (pciBusIdStr ) - 1 , "%04x:%02x:%02x.%d" , cond -> pciBusId .domain , cond -> pciBusId .bus , cond -> pciBusId .device , cond -> pciBusId .func );
166
+ snprintf (pciBusIdStr , ARRAY_SIZE (pciBusIdStr ), "%04x:%02x:%02x.%d" , cond -> pciBusId .domain , cond -> pciBusId .bus , cond -> pciBusId .device , cond -> pciBusId .func );
164
167
165
168
nvmlReturn_t ret = nvmlData .ffnvmlDeviceGetHandleByPciBusId_v2 (pciBusIdStr , & device );
166
169
if (ret != NVML_SUCCESS )
@@ -187,24 +190,28 @@ const char* ffDetectNvidiaGpuInfo(const FFGpuDriverCondition* cond, FFGpuDriverR
187
190
188
191
break ;
189
192
}
190
- if (!device ) return "Device not found" ;
191
193
}
192
194
193
- nvmlBrandType_t brand ;
194
- if (nvmlData .ffnvmlDeviceGetBrand (device , & brand ) == NVML_SUCCESS )
195
+ if (!device ) return "Device not found" ;
196
+
197
+ if (result .type )
195
198
{
196
- switch (brand )
199
+ nvmlBrandType_t brand ;
200
+ if (nvmlData .ffnvmlDeviceGetBrand (device , & brand ) == NVML_SUCCESS )
197
201
{
198
- case NVML_BRAND_NVIDIA_RTX :
199
- case NVML_BRAND_QUADRO_RTX :
200
- case NVML_BRAND_GEFORCE :
201
- case NVML_BRAND_TITAN :
202
- case NVML_BRAND_TESLA :
203
- case NVML_BRAND_QUADRO :
204
- * result .type = FF_GPU_TYPE_DISCRETE ;
205
- break ;
206
- default :
207
- break ;
202
+ switch (brand )
203
+ {
204
+ case NVML_BRAND_NVIDIA_RTX :
205
+ case NVML_BRAND_QUADRO_RTX :
206
+ case NVML_BRAND_GEFORCE :
207
+ case NVML_BRAND_TITAN :
208
+ case NVML_BRAND_TESLA :
209
+ case NVML_BRAND_QUADRO :
210
+ * result .type = FF_GPU_TYPE_DISCRETE ;
211
+ break ;
212
+ default :
213
+ break ;
214
+ }
208
215
}
209
216
}
210
217
0 commit comments