pytorch/docs/source/notes
Dan Johnson d22c4cc353 Add option to use mempool on OOM (#151487)
MemPool is a separate pool of memory handled by the caching allocator. This PR adds the option let the caching allocator try to use this pool as a last resort instead of OOMing by associating a use_on_oom bool with each MemPool.

Usage:
Users can optionally specify a ``use_on_oom`` bool (which is False by default) during MemPool creation. If true, then the CUDACachingAllocator will be able to use memory in this pool as a last resort instead of OOMing.

```
pool = torch.cuda.MemPool(allocator, use_on_oom=True)
with torch.cuda.use_mem_pool(pool):
    a = torch.randn(40 * 1024 * 1024, dtype=torch.uint8, device="cuda")
del a
# at the memory limit, this will succeed by using pool's memory in order to avoid the oom
b = torch.randn(40 * 1024 * 1024, dtype=torch.uint8, device="cuda")
```

Testing:
```
python test/test_cuda.py -k test_mempool_limited_memory_with_allocator
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/151487
Approved by: https://github.com/eqy, https://github.com/syed-ahmed, https://github.com/ngimel
2025-04-26 04:04:57 +00:00
..
amp_examples.rst Update document for autocast on CPU (#135299) 2024-09-13 09:11:47 +00:00
autograd.rst [docs] fix autograd description on convex function case (#148658) 2025-03-13 09:06:15 +00:00
broadcasting.rst
cpu_threading_runtimes.svg
cpu_threading_torchscript_inference.rst
cpu_threading_torchscript_inference.svg
cuda.rst Add option to use mempool on OOM (#151487) 2025-04-26 04:04:57 +00:00
custom_operators.rst Redirect the custom ops landing page :D (#139634) 2024-11-04 22:25:15 +00:00
ddp.rst
extending.func.rst
extending.rst [doc] fix grammar in "Extending Torch" (#140209) 2024-11-13 05:34:43 +00:00
faq.rst
fsdp.rst
get_start_xpu.rst update get start xpu document for v2.7 (#150397) 2025-04-03 18:17:08 +00:00
gradcheck.rst
hip.rst [ROCm] set hipblas workspace (#138791) 2024-10-29 01:37:55 +00:00
large_scale_deployments.rst
libtorch_stable_abi.md Improve stable library apis per Scott's feedback (#152040) 2025-04-24 20:51:03 +00:00
modules.rst Fix to modules.rst: indent line with activation functions (#139667) 2024-11-08 01:12:52 +00:00
mps.rst
multiprocessing.rst Document poison fork note for accelerator APIs (#147507) 2025-04-10 02:37:37 +00:00
numerical_accuracy.rst Add option to configure reduced precision math backend for SDPA (#135964) 2024-09-24 07:11:38 +00:00
out.rst add Out Notes (#151306) 2025-04-24 20:25:09 +00:00
randomness.rst Fix typo in Reproducibility docs (#141341) 2024-11-26 16:53:26 +00:00
serialization.rst Make record/storage alignment in torch.save configurable (#147788) 2025-03-06 12:04:46 +00:00
windows.rst