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 裝置型別匹配。- 返回型別