MCPcopy Create free account
hub / github.com/OpenGVLab/HumanBench / _ignore_torch_cuda_oom

Function _ignore_torch_cuda_oom

PATH/core/memory.py:12–23  ·  view source on GitHub ↗

A context which ignores CUDA OOM exception from pytorch.

()

Source from the content-addressed store, hash-verified

10
11@contextmanager
12def _ignore_torch_cuda_oom():
13 """
14 A context which ignores CUDA OOM exception from pytorch.
15 """
16 try:
17 yield
18 except RuntimeError as e:
19 # NOTE: the string may change?
20 if "CUDA out of memory. " in str(e):
21 pass
22 else:
23 raise
24
25
26def retry_if_cuda_oom(func):

Callers 1

wrappedFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected