torch.xpu.max_memory_allocated¶
- torch.xpu.max_memory_allocated(device=None)[source][source]¶
返回给定设备上 tensors 占用的最大 GPU 内存(以字节为单位)。
默认情况下,这将返回自程序开始以来分配的峰值内存。
reset_peak_memory_stats()
可用于重置跟踪此指标的起点。例如,这两个函数可以测量训练循环中每次迭代的峰值内存使用量。- 参数
device (torch.device 或 int 或 str, 可选) – 选择的设备。如果
device
为None
(默认),则返回当前设备(由current_device()
给定)的统计信息。- 返回类型