HostMemPool#
- class torch.cuda.memory.HostMemPool(*args, **kwargs)[source]#
HostMemPool represents a pool of pinned (page-locked) host memory in the CUDA host caching allocator, with no device memory.
Pinned allocations of a thread inside
use_mem_pool(host_pool)come from this pool, and blocks freed by any thread return to it. The pool keeps its cached blocks apart from other pools; it does not choose where memory is placed. A typical use is one pool per NUMA node, entered by the loader threads bound to that node; see Pinned host memory pools.Creating a pool allocates no memory. A HostMemPool cannot be a CUDA graph’s
pool, but a graph keeps the pool until it is reset if the pool’s context is entered while the current stream is capturing into the graph. Deleting the pool frees its cached blocks, or, if a graph keeps the pool, the reset of the last such graph does; what remains is freed by a latertorch.accelerator.empty_host_cache().