Class GPUContextPool
- java.lang.Object
- 
- org.apache.sysds.runtime.instructions.gpu.context.GPUContextPool
 
- 
 public class GPUContextPool extends Object 
- 
- 
Field SummaryFields Modifier and Type Field Description static StringAVAILABLE_GPUSGPUs to use, can specify -1 to use all, comma separated list of GPU numbers, a specific GPU or a range
 - 
Constructor SummaryConstructors Constructor Description GPUContextPool()
 - 
Method SummaryAll Methods Static Methods Concrete Methods Modifier and Type Method Description static voidfreeAllGPUContexts()Unreserves all GPUContextsstatic intgetAvailableCount()Get the number of free GPUContextsstatic intgetDeviceCount()Number of available devices on this machinestatic longinitialGPUMemBudget()Gets the initial GPU memory budget.static voidinitializeGPU()Static initialization of the number of devices Also sets behaviour for J{Cuda, Cudnn, Cublas, Cusparse} in case of error Initializes the CUDA driver All these need be done once, and not per GPUstatic ArrayList<Integer>parseListString(String str, int max)Parses a string into a list.static List<GPUContext>reserveAllGPUContexts()Reserves and gets an initialized list of GPUContexts
 
- 
- 
- 
Field Detail- 
AVAILABLE_GPUSpublic static String AVAILABLE_GPUS GPUs to use, can specify -1 to use all, comma separated list of GPU numbers, a specific GPU or a range
 
- 
 - 
Method Detail- 
initializeGPUpublic static void initializeGPU() Static initialization of the number of devices Also sets behaviour for J{Cuda, Cudnn, Cublas, Cusparse} in case of error Initializes the CUDA driver All these need be done once, and not per GPU
 - 
parseListStringpublic static ArrayList<Integer> parseListString(String str, int max) Parses a string into a list. The string can be of these forms: 1. "-1" : all integers from range 0 to max - [0,1,2,3....max] 2. "2,3,0" : comma separated list of integers - [0,2,3] 3. "4" : a specific integer - [4] 4. "0-4" : a range of integers - [0,1,2,3,4] In ranges and comma separated lists, all values must be positive. Anything else is invalid.- Parameters:
- str- input string
- max- maximum range of integers
- Returns:
- the list of integers in the parsed string
 
 - 
reserveAllGPUContextspublic static List<GPUContext> reserveAllGPUContexts() Reserves and gets an initialized list of GPUContexts- Returns:
- null if no GPUContexts in pool, otherwise a valid list of GPUContext
 
 - 
getAvailableCountpublic static int getAvailableCount() Get the number of free GPUContexts- Returns:
- number of free GPUContexts
 
 - 
getDeviceCountpublic static int getDeviceCount() Number of available devices on this machine- Returns:
- number of available GPUs on this machine
 
 - 
freeAllGPUContextspublic static void freeAllGPUContexts() Unreserves all GPUContexts
 - 
initialGPUMemBudgetpublic static long initialGPUMemBudget() throws RuntimeExceptionGets the initial GPU memory budget. This is the minimum of the available memories across all the GPUs on the machine(s)- Returns:
- minimum available memory
- Throws:
- RuntimeException- if error initializing the GPUs
 
 
- 
 
-