评价此页

torch.accelerator.memory.max_memory_allocated#

torch.accelerator.memory.max_memory_allocated(device_index=None, /)[源代码]#

返回给定设备索引下,张量在 accelerator 上占用的当前最大设备内存(以字节为单位)。

默认情况下,此函数返回自程序开始以来的峰值分配内存。可以使用 reset_peak_memory_stats() 来重置此指标的跟踪起点。

参数

device_index (torch.device, str, int, optional) – 要定位的设备索引。如果未给出,则默认使用 torch.accelerator.current_device_index()。如果提供了 torch.device 或 str,则其类型必须与当前的 accelerator 设备类型匹配。

返回类型

int