評價此頁

torch.cuda.memory.host_memory_stats#

torch.cuda.memory.host_memory_stats()[原始碼]#

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

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

核心統計資訊

  • "allocated.{current,peak,allocated,freed}":分配器收到的分配請求數量。

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

  • "segment.{current,peak,allocated,freed}":從 cudaMalloc() 保留的段數。

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

對於這些核心統計資訊,值按以下方式細分。

指標型別

  • current:此指標的當前值。

  • peak:此指標的最大值。

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

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

除了核心統計資料外,我們還提供了一些簡單的事件計數器

  • "num_host_alloc":CUDA 分配呼叫的數量。這包括 cudaHostAlloc 和 cudaHostRegister。

  • "num_host_free":CUDA 釋放呼叫的數量。這包括 cudaHostFree 和 cudaHostUnregister。

最後,我們還提供了一些簡單的計時計數器

  • "host_alloc_time.{total,max,min,count,avg}":透過 CUDA 呼叫進行的分配請求的計時。

  • "host_free_time.{total,max,min,count,avg}":透過 CUDA 呼叫進行的釋放請求的計時。

對於這些計時統計資訊,值分解如下。

指標型別

  • total:花費的總時間。

  • max:每次呼叫的最大值。

  • min:每次呼叫的最小值。

  • count:呼叫次數。

  • avg:每次呼叫的平均時間。

返回型別

dict[str, Any]