Skip to content

CUDA stream capture error after OOM recovery with torch.compile + CUDA graphs #6

Closed

Description

@beastoin

Summary

Parakeet ASR service using NeMo's parakeet-tdt-0.6b-v3 batch model enters an unrecoverable error state after a CUDA OOM event when running with torch.compile + CUDA graphs enabled. Every subsequent transcription request fails with a CUDA stream capture error, and the service cannot self-recover without a full pod delete (container restart is insufficient).

Environment

  • Model: nvidia/parakeet-tdt-0.6b-v3 (TDT — CTC+transducer hybrid, resolved via EncDecRNNTBPEModel)
  • Inference mode: NeMo
  • GPU: NVIDIA L4 (22 GiB VRAM)
  • CUDA: 13.0, Driver 580.126.20
  • NeMo: installed via pip (collections.asr)
  • PyTorch: with torch.compile enabled
  • Config: PARAKEET_TORCH_COMPILE=true, PARAKEET_CUDA_GRAPHS=true
  • Container resource limit: 20Gi RAM, 1x GPU

Code Path

The crash is on the batch transcription path, not the streaming model:

  • Batch (/v1/transcribe, /v2/transcribe): main.py → batch_engine.py:103 submit → batch_engine.py:137 _flush_batch → gpu_worker.py:134 _run_loop → gpu_worker.py:208 _batch_transcribe → NeMo rnnt_models.py:317 transcribe
  • The streaming model (parakeet-rnnt-1.1b loaded by stream_handler.py for /v3/stream WebSocket) is not involved.

Note: rnnt_models.py appears in the traceback because TDT extends RNNT architecture in NeMo — the base transducer .transcribe() logic lives there. This does not mean the RNNT streaming model was loaded.

Sequence of Events

  1. Under load, a transcription batch triggers CUDA OOM during move_data_to_device() in NeMo's transcription.py:

    torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 366.00 MiB.
    GPU 0 has a total capacity of 22.03 GiB of which 127.12 MiB is free.
    Including non-PyTorch memory, this process has 21.89 GiB memory in use.
    Of the allocated memory 21.10 GiB is allocated by PyTorch, and 479.55 MiB is reserved by PyTorch but unallocated.
    
  2. Container is OOMKilled (exit code 137) and Kubernetes restarts it (restart count reached 3).

  3. After restart, every transcription request fails with:

    torch.AcceleratorError: CUDA error: operation not permitted when stream is capturing
    Search for `cudaErrorStreamCaptureUnsupported'
    

    The error occurs in pin_memory() during the PyTorch DataLoader iteration:

    File "torch/utils/data/_utils/pin_memory.py", line 57, in pin_memory
        return data.pin_memory()
    
  4. The health endpoint (GET /health) continues returning 200, so Kubernetes keeps routing traffic — but it can never serve a request. The health check at gpu_worker.py:71-72 checks self._running and self._ready.is_set() and self._load_error is None — it verifies initial model load success only, with no ongoing GPU liveness probe.

  5. Container restarts do not fix this — the GPU device retains corrupted CUDA graph/stream capture state across process restarts within the same pod. Only a full pod delete (releasing and reattaching the GPU device) recovers the service.

  6. nvidia-smi during the stuck state showed: 5050 MiB used, 0% GPU utilization — model loaded in VRAM but not processing.

Reproduction

  1. Deploy parakeet with PARAKEET_TORCH_COMPILE=true and PARAKEET_CUDA_GRAPHS=true on an L4 GPU
  2. Send concurrent transcription requests until VRAM is exhausted
  3. Wait for OOM kill and container restart
  4. All subsequent requests fail with stream capture error
  5. Health endpoint returns 200 throughout

Activity

  1. beastoin commented on Jun 20, 2026

    @beastoin
    OwnerAuthor

    Correction: Model Identity

    The original report implied the streaming model (parakeet-rnnt-1.1b) was involved. After code review, this is incorrect — the crash is on the batch model (parakeet-tdt-0.6b-v3).

    Why rnnt_models.py appears in the traceback

    The rnnt_models.py:317 in the stack trace is misleading. parakeet-tdt-0.6b-v3 is a TDT model (CTC+transducer hybrid), but NeMo resolves it through EncDecRNNTBPEModel because TDT extends the RNNT architecture. The .transcribe() method flows through rnnt_models.py because that's where the base transducer transcription logic lives — not because the RNNT streaming model was loaded.

    Code paths

    • Batch (/v1/transcribe, /v2/transcribe): main.py → batch_engine.py → gpu_worker.py → GPUWorker(model_name=PARAKEET_MODEL) → loads nvidia/parakeet-tdt-0.6b-v3 via EncDecRNNTBPEModel class resolution
    • Streaming (/v3/stream WebSocket): stream_handler.py → loads nvidia/parakeet-rnnt-1.1b — completely separate, not involved in this crash

    Health endpoint gap

    gpu_worker.py:71-72 — is_ready checks self._running and self._ready.is_set() and self._load_error is None. Once the model loads successfully on startup, is_ready stays True permanently — there is no ongoing GPU liveness probe. This is why the health endpoint returned 200 while the GPU was in a broken CUDA state.

    Updated suggested fix for health check

    # In gpu_worker.py, add GPU liveness to is_ready:
    @property
    def is_ready(self) -> bool:
        if not (self._running and self._ready.is_set() and self._load_error is None):
            return False
        try:
            torch.cuda.current_stream().synchronize()
            return True
        except torch.AcceleratorError:
            return False

    This would cause the readiness probe to fail after a CUDA error, triggering Kubernetes to restart the pod automatically.

  2. beastoin commented on Jun 28, 2026

    @beastoin
    OwnerAuthor

    Addressed by PR #12 — OOM recovery with torch.cuda.empty_cache() added to all GPU dispatch paths (single, pool, prefetch, stream batch). Observable via gpu.oom_recovered counter in /metrics endpoint.

    Prod data showed VRAM ratcheted 16→19→20→22 GiB across 4-5 OOMs because failed batches leaked tensors without cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions