torch.xpu.max_memory_allocated

torch.xpu.max_memory_allocated(device=None)[源代码]

以字节为单位返回给定设备上张量占用的最大 GPU 内存。

默认情况下,这会返回自程序启动以来的峰值分配内存。可以使用reset_peak_memory_stats() 重置跟踪此指标的起点。例如,这两个函数可以用来测量训练循环中每个迭代的峰值内存使用情况。

参数

device (torch.deviceintstr, 可选) – 选定的设备。如果 deviceNone(默认值),则返回当前设备的统计信息,该信息由 current_device() 提供。

返回类型

int

本页目录