Use when dealing with GPU memory issues, CUDA OOM errors, training crashes, or optimizing memory usage in BayesFlow training. Triggers on: OOM, out of memory, CUDA error, memory error, batch size, gradient checkpointing, memory probe, memory budget, VRAM, GPU memory.
Detect CUDA out-of-memory errors in exception chains:
from bayesflow_irt import is_oom_error
def is_oom_error(exc: BaseException) -> bool:
msg = str(exc).lower()
return "out of memory" in msg or "cudaerrormemoryallocation" in msg
Automatic retry with halved batch size on OOM:
from bayesflow_irt import fit_with_oom_retry, FitResult