快捷方式

torch.xpu.memory_stats

torch.xpu.memory_stats(device=None)[source][source]

返回給定裝置的 XPU 記憶體分配器統計資訊的字典。

此函式的返回值是一個統計資訊字典,其中每個統計資訊都是一個非負整數。

核心統計資訊

  • "allocated_bytes.{all,large_pool,small_pool}.{current,peak,allocated,freed}":已分配的記憶體量。

  • "reserved_bytes.{all,large_pool,small_pool}.{current,peak,allocated,freed}":保留的記憶體量。

  • "active_bytes.{all,large_pool,small_pool}.{current,peak,allocated,freed}":活動的記憶體量。

  • "requested_bytes.{all,large_pool,small_pool}.{current,peak,allocated,freed}":客戶端程式碼請求的記憶體,將其與 allocated_bytes 進行比較,以檢查分配舍入是否增加了太多開銷。

這些核心統計資訊的數值細分如下。

池型別

  • all:所有記憶體池的合併統計資訊。

  • large_pool:大型分配池的統計資訊(用於大小 >= 1MB 的分配)。

  • small_pool:小型分配池的統計資訊(用於大小 < 1MB 的分配)。

指標型別

  • current:此指標的當前值。

  • peak:此指標的最大值。

  • allocated:此指標的歷史總增加量。

  • freed:此指標的歷史總減少量。

引數

device (torch.deviceintstr可選) – 選擇的裝置。如果 deviceNone(預設),則返回由 current_device() 給定的當前裝置的統計資訊。

返回型別

dict[str, Any]

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取面向初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源