Class GPUContextPool
java.lang.Object
org.apache.sysds.runtime.instructions.gpu.context.GPUContextPool
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic StringGPUs to use, can specify -1 to use all, comma separated list of GPU numbers, a specific GPU or a range -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidUnreserves all GPUContextsstatic intGet the number of free GPUContextsstatic intNumber of available devices on this machinestatic longGets the initial GPU memory budget.static voidStatic 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 GPUparseListString(String str, int max) Parses a string into a list.static List<GPUContext>Reserves and gets an initialized list of GPUContexts
-
Field Details
-
AVAILABLE_GPUS
GPUs to use, can specify -1 to use all, comma separated list of GPU numbers, a specific GPU or a range
-
-
Constructor Details
-
GPUContextPool
public GPUContextPool()
-
-
Method Details
-
initializeGPU
public 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 -
parseListString
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 stringmax- maximum range of integers- Returns:
- the list of integers in the parsed string
-
reserveAllGPUContexts
Reserves and gets an initialized list of GPUContexts- Returns:
- null if no GPUContexts in pool, otherwise a valid list of GPUContext
-
getAvailableCount
public static int getAvailableCount()Get the number of free GPUContexts- Returns:
- number of free GPUContexts
-
getDeviceCount
public static int getDeviceCount()Number of available devices on this machine- Returns:
- number of available GPUs on this machine
-
freeAllGPUContexts
public static void freeAllGPUContexts()Unreserves all GPUContexts -
initialGPUMemBudget
Gets 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
-