cuvs.common#

3 min read time

Applies to Linux

Submodules#

Classes#

MultiGpuResources

Multi-GPU Resources is a lightweight python wrapper around the

Resources

Resources is a lightweight python wrapper around the corresponding

Functions#

auto_sync_multi_gpu_resources(f)

auto_sync_multi_gpu_resources(f)

auto_sync_resources(f)

auto_sync_resources(f)

Package Contents#

class cuvs.common.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.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

class cuvs.common.Resources#

Resources is a lightweight python wrapper around the corresponding C++ class of resources exposed by RAFT’s C++ interface. Refer to the header file raft/core/resources.hpp for interface level details of this struct.

Parameters#

stream : Optional stream to use for ordering CUDA instructions

Examples#

Basic usage:

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

Using a cuPy stream with cuVS Resources:

>>> import cupy
>>> from cuvs.common import Resources
>>>
>>> cupy_stream = cupy.cuda.Stream()
>>> handle = Resources(stream=cupy_stream.ptr)
static __reduce__(*args, **kwargs)#

Resources.__reduce_cython__(self)

static __setstate__(*args, **kwargs)#

Resources.__setstate_cython__(self, __pyx_state)

get_c_obj()#

Resources.get_c_obj(self)

Return the pointer to the underlying c_obj as a size_t

sync()#

Resources.sync(self)

cuvs.common.auto_sync_resources(f)#

auto_sync_resources(f)

Decorator to automatically call sync on a cuVS 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 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