memory_reserved

paddle.cuda. memory_reserved ( device: DeviceLike = None ) int [source]

Return the current device memory managed by the caching allocator in bytes for a given device.

Parameters

device (DeviceLike, optional) – The device to query. If None, use the current device. Can be paddle.CUDAPlace, paddle.CustomPlace, paddle.XPUPlace, int (device index), or str (device string).

Returns

The current memory managed by the caching allocator in bytes.

Return type

int

Examples

>>> 
>>> import paddle
>>> # Get memory reserved for current device
>>> mem_reserved = paddle.cuda.memory_reserved()
>>> print(f"Memory reserved: {mem_reserved} bytes")
>>>
>>> # Get memory reserved for specific device
>>> mem_reserved = paddle.cuda.memory_reserved(0)
>>> print(f"Memory reserved on device 0: {mem_reserved} bytes")