diff --git a/src/com/sheepit/client/hardware/gpu/CUDA.java b/src/com/sheepit/client/hardware/gpu/CUDA.java index ed40ebb..76d22ec 100644 --- a/src/com/sheepit/client/hardware/gpu/CUDA.java +++ b/src/com/sheepit/client/hardware/gpu/CUDA.java @@ -33,6 +33,6 @@ public interface CUDA extends Library { 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); } diff --git a/src/com/sheepit/client/hardware/gpu/GPU.java b/src/com/sheepit/client/hardware/gpu/GPU.java index c5cf0fd..1bd9d4d 100644 --- a/src/com/sheepit/client/hardware/gpu/GPU.java +++ b/src/com/sheepit/client/hardware/gpu/GPU.java @@ -91,7 +91,13 @@ public class GPU { } 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) { System.out.println("GPU::generate cuDeviceTotalMem failed (ret: " + CUresult.stringFor(result) + ")");