memory_allocated
- paddle.cuda. memory_allocated ( device: DeviceLike = None ) int [source]
-
Return the current device memory occupied by tensors 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 occupied by tensors in bytes.
- Return type
-
int
Examples
>>> >>> import paddle >>> # Get memory allocated for current device >>> mem_allocated = paddle.cuda.memory_allocated() >>> print(f"Memory allocated: {mem_allocated} bytes") >>> >>> # Get memory allocated for specific device >>> mem_allocated = paddle.cuda.memory_allocated(0) >>> print(f"Memory allocated on device 0: {mem_allocated} bytes")
