cuda.core.experimental.DeviceMemoryResource#
- class cuda.core.experimental.DeviceMemoryResource(device_id: int | Device, options=None)#
Create a device memory resource managing a stream-ordered memory pool.
- Parameters:
device_id (int | Device) – Device or Device ordinal for which a memory resource is constructed.
options (DeviceMemoryResourceOptions) –
Memory resource creation options.
If set to None, the memory resource uses the driver’s current stream-ordered memory pool for the specified device_id. If no memory pool is set as current, the driver’s default memory pool for the device is used.
If not set to None, a new memory pool is created, which is owned by the memory resource.
When using an existing (current or default) memory pool, the returned device memory resource does not own the pool (is_handle_owned is False), and closing the resource has no effect.
Methods
- allocate(
- self,
- size_t size,
- stream: Stream = None,
Allocate a buffer of the requested size.
- Parameters:
- Returns:
The allocated buffer object, which is accessible on the device that this memory resource was created for.
- Return type:
- close(self)#
Close the device memory resource and destroy the associated memory pool if owned.
- deallocate(
- self,
- ptr: DevicePointerT,
- size_t size,
- stream: Stream = None,
Deallocate a buffer previously allocated by this resource.
- Parameters:
ptr (
DevicePointerT
) – The pointer or handle to the buffer to deallocate.size (int) – The size of the buffer to deallocate, in bytes.
stream (Stream, optional) – The stream on which to perform the deallocation asynchronously. If None, an internal stream is used.
- cls,
- device_id: int | Device,
- IPCChannel channel: IPCChannel,
Create a device memory resource from a memory pool shared over an IPC channel.
- self,
- IPCChannel channel: IPCChannel,
Attributes
- property attributes: DeviceMemoryResourceAttributes#
- property handle: cuda.bindings.driver.CUmemoryPool#
Handle to the underlying memory pool.
- property is_device_accessible: bool#
Return True. This memory resource provides device-accessible buffers.
- property is_handle_owned: bool#
Whether the memory resource handle is owned. If False,
close
has no effect.
- property is_host_accessible: bool#
Return False. This memory resource does not provide host-accessible buffers.