Bugfix: detection of GPU vram over 4GB

This commit is contained in:
intrigus
2017-02-28 12:55:12 +01:00
committed by Laurent Clouet
parent e883148c89
commit ddac792ab7
2 changed files with 8 additions and 2 deletions

View File

@@ -33,6 +33,6 @@ public interface CUDA extends Library {
public int cuDeviceGetName(byte[] name, int len, int dev); public int cuDeviceGetName(byte[] name, int len, int dev);
// http://en.wikipedia.org/wiki/Java_Native_Access public int cuDeviceTotalMem_v2(LongByReference bytes, int dev);
public int cuDeviceTotalMem(LongByReference bytes, int dev); public int cuDeviceTotalMem(LongByReference bytes, int dev);
} }

View File

@@ -91,7 +91,13 @@ public class GPU {
} }
LongByReference ram = new LongByReference(); LongByReference ram = new LongByReference();
result = cudalib.cuDeviceTotalMem(ram, num); try {
result = cudalib.cuDeviceTotalMem_v2(ram, num);
}
catch (UnsatisfiedLinkError e) {
// fall back to old function
result = cudalib.cuDeviceTotalMem(ram, num);
}
if (result != CUresult.CUDA_SUCCESS) { if (result != CUresult.CUDA_SUCCESS) {
System.out.println("GPU::generate cuDeviceTotalMem failed (ret: " + CUresult.stringFor(result) + ")"); System.out.println("GPU::generate cuDeviceTotalMem failed (ret: " + CUresult.stringFor(result) + ")");