torch.xpu.empty_cache — PyTorch 2.7 documentation (original) (raw)

torch.xpu.empty_cache()[source][source]

Release all unoccupied cached memory currently held by the caching allocator so that those can be used in other XPU application.

Note

empty_cache() doesn’t increase the amount of XPU memory available for PyTorch. However, it may help reduce fragmentation of XPU memory in certain cases.