Bugfix: Crash when access to nvml api is unavailable (#1252)

This commit is contained in:
sebastian-dev
2024-03-25 17:08:15 +01:00
committed by GitHub
parent 4fb49c5e80
commit ea5d28166c
+46 -11
View File
@@ -295,8 +295,15 @@ internal static class NvidiaML
return nvmlDevice;
}
}
else if (_windowsNvmlDeviceGetHandleByIndex(index, out nvmlDevice) == NvmlReturn.Success)
return nvmlDevice;
else
{
try
{
if (_windowsNvmlDeviceGetHandleByIndex(index, out nvmlDevice) == NvmlReturn.Success)
return nvmlDevice;
}
catch { }
}
}
return null;
@@ -312,8 +319,15 @@ internal static class NvidiaML
if (nvmlDeviceGetHandleByPciBusId(pciBusId, out nvmlDevice) == NvmlReturn.Success)
return nvmlDevice;
}
else if (_windowsNvmlDeviceGetHandleByPciBusId(pciBusId, out nvmlDevice) == NvmlReturn.Success)
return nvmlDevice;
else
{
try
{
if (_windowsNvmlDeviceGetHandleByPciBusId(pciBusId, out nvmlDevice) == NvmlReturn.Success)
return nvmlDevice;
}
catch { }
}
}
return null;
@@ -329,8 +343,15 @@ internal static class NvidiaML
if (nvmlDeviceGetPowerUsage(nvmlDevice, out powerUsage) == NvmlReturn.Success)
return powerUsage;
}
else if (_windowsNvmlDeviceGetPowerUsage(nvmlDevice, out powerUsage) == NvmlReturn.Success)
return powerUsage;
else
{
try
{
if (_windowsNvmlDeviceGetPowerUsage(nvmlDevice, out powerUsage) == NvmlReturn.Success)
return powerUsage;
}
catch { }
}
}
return null;
@@ -346,8 +367,15 @@ internal static class NvidiaML
if (nvmlDeviceGetPcieThroughput(nvmlDevice, counter, out pcieThroughput) == NvmlReturn.Success)
return pcieThroughput;
}
else if (_windowsNvmlDeviceGetPcieThroughputDelegate(nvmlDevice, counter, out pcieThroughput) == NvmlReturn.Success)
return pcieThroughput;
else
{
try
{
if (_windowsNvmlDeviceGetPcieThroughputDelegate(nvmlDevice, counter, out pcieThroughput) == NvmlReturn.Success)
return pcieThroughput;
}
catch { }
}
}
return null;
@@ -364,8 +392,15 @@ internal static class NvidiaML
if (nvmlDeviceGetPciInfo(nvmlDevice, ref pci) == NvmlReturn.Success)
return pci;
}
else if (_windowsNvmlDeviceGetPciInfo(nvmlDevice, ref pci) == NvmlReturn.Success)
return pci;
else
{
try
{
if (_windowsNvmlDeviceGetPciInfo(nvmlDevice, ref pci) == NvmlReturn.Success)
return pci;
}
catch { }
}
}
return null;
@@ -439,4 +474,4 @@ internal static class NvidiaML
public uint reserved2;
public uint reserved3;
}
}
}