[Platform] Replace torch.cuda.mem_get_info with torch.accelerator.get_memory_info (#44825)

Signed-off-by: Kunshang Ji <kunshang.ji@intel.com>
Signed-off-by: Kunshang Ji <jikunshang95@gmail.com>
This commit is contained in:
Kunshang Ji
2026-06-30 14:39:52 +08:00
committed by GitHub
parent 0feca7ffa8
commit fb42e5219e
17 changed files with 56 additions and 52 deletions
@@ -29,9 +29,8 @@ def _gpu_snapshot(tag: str, prev_alloc: float = 0.0) -> dict:
torch.accelerator.synchronize()
alloc = torch.accelerator.memory_allocated()
reserved = torch.accelerator.memory_reserved()
# mem_get_info is not available on torch.accelerator
try:
drv_free, drv_total = torch.cuda.mem_get_info()
drv_free, drv_total = torch.accelerator.get_memory_info()
drv_used = drv_total - drv_free
drv_pct = drv_used / drv_total * 100
except Exception: