Class GPUContextPool


  • public class GPUContextPool
    extends Object
    • Field Detail

      • AVAILABLE_GPUS

        public 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
    • Constructor Detail

      • GPUContextPool

        public GPUContextPool()
    • Method Detail

      • 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

        public 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
      • reserveAllGPUContexts

        public 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
      • 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

        public static long initialGPUMemBudget()
                                        throws RuntimeException
        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