vmm_compact

paddle.device.cuda. vmm_compact ( device: _CudaPlaceLike | None = None ) int [source]

Defragment the free memory blocks managed by the Virtual Memory Management (VMM) allocator of the given device.

Parameters

device (paddle.CUDAPlace|int|str|None, optional) – The device, the id of the device or the string name of device like ‘gpu:x’. If device is None, the device is the current device. Default: None.

Returns

The amount of memory (in bytes) that was moved during the compaction.

Return type

int

Examples

>>> 
>>> import paddle
>>> paddle.device.set_device('gpu')  # or '<custom_device>'

>>> moved_bytes = paddle.device.cuda.vmm_compact(0)
>>> print(f"Bytes moved during compaction: {moved_bytes}")