Read Nvidia Driver version via NVML

This commit is contained in:
harlekin
2023-01-06 14:19:34 +00:00
parent aaa1b466dd
commit 1bf519c9c3
9 changed files with 115 additions and 27 deletions
@@ -28,6 +28,8 @@ public class GPUDevice {
private String oldId; // for backward compatibility
private String driverVersion;
public GPUDevice(String type, String model, long ram, String id) {
this.type = type;
this.model = model;
@@ -80,7 +82,34 @@ public class GPUDevice {
this.oldId = id;
}
public String getDriverVersion() {
return this.driverVersion;
}
public void setDriverVersion(String driverVersion) {
this.driverVersion = driverVersion;
}
@Override public String toString() {
return "GPUDevice [type=" + type + ", model='" + model + "', memory=" + memory + ", id=" + id + "]";
return "GPUDevice [type=" + type + ", model='" + model + "', memory=" + memory + ", id=" + id + ", driverVersion=" + driverVersion + "]";
}
public static int compareVersions(String version1, String version2) {
int comparisonResult = 0;
String[] version1Splits = version1.split("\\.");
String[] version2Splits = version2.split("\\.");
int maxLengthOfVersionSplits = Math.max(version1Splits.length, version2Splits.length);
for (int i = 0; i < maxLengthOfVersionSplits; i++){
Integer v1 = i < version1Splits.length ? Integer.parseInt(version1Splits[i]) : 0;
Integer v2 = i < version2Splits.length ? Integer.parseInt(version2Splits[i]) : 0;
int compare = v1.compareTo(v2);
if (compare != 0) {
comparisonResult = compare;
break;
}
}
return comparisonResult;
}
}