public boolean pingDeviceForFreeMemory ( Integer deviceId , long requiredMemory ) { /* long[] totalMem = new long[1]; long[] freeMem = new long[1]; JCuda.cudaMemGetInfo(freeMem, totalMem); long free = freeMem[0]; long total = totalMem[0]; long used = total - free; /* We don't want to allocate memory if it's too close to the end of available ram. */ //if (configuration != null && used > total * configuration.getMaxDeviceMemoryUsed()) return false; /* if (free + requiredMemory < total * 0.85) return true; else return false; */ long freeMem = nativeOps . getDeviceFreeMemory ( - 1 ) ; if ( freeMem - requiredMemory < DEVICE_RESERVED_SPACE ) return false ; else return true ; }
This method checks specified device for specified amount of memory