cuvs.common.mg_resources#

2 min read time

Applies to Linux

Classes#

MultiGpuResources

Multi-GPU Resources is a lightweight python wrapper around the

Functions#

check_cuvs(status)

check_cuvs(cuvsError_t status: cuvsError_t)

auto_sync_multi_gpu_resources(f)

auto_sync_multi_gpu_resources(f)

Module Contents#

cuvs.common.mg_resources.check_cuvs(status: cuvsError_t)#

check_cuvs(cuvsError_t status: cuvsError_t)

Converts a status code into an exception

class cuvs.common.mg_resources.MultiGpuResources#

Multi-GPU Resources is a lightweight python wrapper around the corresponding C++ class of multi-GPU resources exposed by RAFT’s C++ interface. This class provides a handle for multi-GPU operations across all available GPUs.

Parameters#

streamint, optional

A CUDA stream pointer to use for this resource handle. If None, a default stream will be used.

device_idslist of int, optional

A list of device IDs to use for multi-GPU operations. If None, all available GPUs will be used.

Examples#

Basic usage:

>>> from cuvs.common import MultiGpuResources
>>> handle = MultiGpuResources()
>>>
>>> # call multi-GPU algos here
>>>
>>> # final sync of all work launched in the stream of this handle
>>> handle.sync()

Using a cuPy stream with cuVS Multi-GPU Resources:

>>> import cupy
>>> from cuvs.common import MultiGpuResources
>>>
>>> cupy_stream = cupy.cuda.Stream()
>>> handle = MultiGpuResources(stream=cupy_stream.ptr)

Using specific device IDs:

>>> from cuvs.common import MultiGpuResources
>>> handle = MultiGpuResources(device_ids=[0])
>>>
>>> # call multi-GPU algos here
>>>
>>> handle.sync()
static __reduce__(*args, **kwargs)#

MultiGpuResources.__reduce_cython__(self)

static __setstate__(*args, **kwargs)#

MultiGpuResources.__setstate_cython__(self, __pyx_state)

get_c_obj()#

MultiGpuResources.get_c_obj(self)

Return the pointer to the underlying c_obj as a size_t

set_memory_pool(percent_of_free_memory)#

MultiGpuResources.set_memory_pool(self, percent_of_free_memory)

Set a memory pool on all devices managed by these resources.

Parameters#

percent_of_free_memoryint

Percentage of free device memory to allocate for the pool.

Examples#

>>> from cuvs.common import MultiGpuResources
>>> handle = MultiGpuResources()
>>> handle.set_memory_pool(80)  # Use 80% of free memory
sync()#

MultiGpuResources.sync(self)

cuvs.common.mg_resources.auto_sync_multi_gpu_resources(f)#

auto_sync_multi_gpu_resources(f)

Decorator to automatically call sync on a cuVS Multi-GPU Resources object when it isn’t passed to a function.

When a resources=None is passed to the wrapped function, this decorator will automatically create a default multi-GPU resources for the function, and call sync on that resources when the function exits.

This will also insert the appropriate docstring for the resources parameter