def _ignore_torch_cuda_oom():
    """
    A context which ignores CUDA OOM exception from pytorch.
    """
    try:
        yield
    except RuntimeError as e:
        # NOTE: the string may change?
        if "CUDA out of memory. " in str(e):
            pass
        else:
            raise

    A context which ignores CUDA OOM exception from pytorch.
    
ControlNet-v1-1-nightly/annotator/oneformer/detectron2/utils/memory.py