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.check_textures_availability()[source]¶
Check whether Cuda textures can be used. The only limitation is pycuda which does not support texture objects. Textures references were deprecated, and removed from Cuda 12.
- 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.
- nabu.cuda.utils.copy_big_gpuarray(dst, src, itemsize=4, checks=False)[source]¶
Copy a big pycuda.gpuarray.GPUArray into another. Transactions of more than 2**32 -1 octets fail, so are doing several partial copies of smaller arrays.