nabu.cuda.utils module¶
- nabu.cuda.utils.get_cuda_context(device_id=None, cleanup_at_exit=True)[source]¶
Create or get a CUDA context.
- nabu.cuda.utils.get_gpu_memory(device_id)[source]¶
Return the total memory (in GigaBytes) of a device.
- nabu.cuda.utils.detect_cuda_gpus()[source]¶
Detect the available Nvidia CUDA GPUs on the current host.
- Returns:
gpus (dict) – Dictionary where the key is the GPU ID, and the value is a pycuda.driver.Device object.
error_msg (str) – In the case where there is an error, the message is returned in this item. Otherwise, it is a None object.
- nabu.cuda.utils.collect_cuda_gpus()[source]¶
Return a dictionary of GPU ids and brief description of each CUDA-compatible GPU with a few fields.
- nabu.cuda.utils.copy_array(dst, src, check=False, src_dtype=None, dst_x_in_bytes=0, dst_y=0)[source]¶
Copy a source array to a destination array. Source and destination can be either numpy.ndarray, pycuda.Driver.Array, or pycuda.gpuarray.GPUArray.
- Parameters:
dst (pycuda.driver.Array or pycuda.gpuarray.GPUArray or numpy.ndarray) – Destination array. Its content will be overwritten by copy.
src (pycuda.driver.Array or pycuda.gpuarray.GPUArray or numpy.ndarray) – Source array.
check (bool, optional) – Whether to check src and dst shape and data type.