Skip to content

nabu.resources.gpu

source module nabu.resources.gpu

gpu.py: general-purpose utilities for GPU

Classes

  • GPUDescription Simple description of a Graphical Processing Unit. This class is designed to be simple to understand, and to be serializable for being used by dask.distributed.

Functions

source class GPUDescription(device, vendor=None, device_id=None)

Simple description of a Graphical Processing Unit. This class is designed to be simple to understand, and to be serializable for being used by dask.distributed.

Create a description from a device.

Parameters

  • device : pycuda.<span class="mkapi-tooltip" title="pycuda.driver">driver</span>.<span class="mkapi-tooltip" title="pycuda.driver.Device">Device</span> or pyopencl.<span class="mkapi-tooltip" title="pyopencl.Device">Device</span> Class describing a GPU device.

Methods

source method GPUDescription.get_dict()

source pick_gpus(method, cuda_gpus, opencl_platforms, n_gpus)

source pick_gpus_auto(cuda_gpus, opencl_platforms, n_gpus)

Pick n_gpus devices with the best available driver.

This function browse the visible Cuda GPUs and Opencl platforms to pick the GPUs with the best driver. A worker might see several implementations of a GPU driver. For example with Nvidia hardware, we can see: - The Cuda implementation (nvidia-cuda-toolkit) - OpenCL implementation by Nvidia (nvidia-opencl-icd) - OpenCL implementation by Portable OpenCL

Parameters

  • cuda_gpu : dict Dictionary where each key is an ID, and the value is a dictionary describing some attributes of the GPU (obtained with GPUDescription)

  • opencl_platforms : dict Dictionary where each key is the platform name, and the value is a list of dictionary descriptions.

  • n_gpus : int Number of GPUs to pick.

Raises

  • ValueError

source pick_gpus_nvidia(cuda_gpus, n_gpus)

Pick one or more Nvidia GPUs.

Raises

  • ValueError