W3cubDocs

/PyTorch 2.9

torch.accelerator.memory.max_memory_reserved

torch.accelerator.memory.max_memory_reserved(device_index=None, /) [source]

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

By default, this returns the peak cached memory since the beginning of this program. reset_peak_memory_stats() can be used to reset the starting point in tracking this metric.

Parameters

device_index (torch.device, str, int, optional) – the index of the device to target. If not given, use torch.accelerator.current_device_index() by default. If a torch.device or str is provided, its type must match the current accelerator device type.

Return type

int

© 2025, PyTorch Contributors
PyTorch has a BSD-style license, as found in the LICENSE file.
https://docs.pytorch.org/docs/2.9/generated/torch.accelerator.memory.max_memory_reserved.html