SGLang torch.OutOfMemoryError: CUDA out of memory
Fix SGLang torch.OutOfMemoryError during RadixCache allocation, CUDA graph warmup, or high-concurrency serving by tuning --mem-fraction-static and batching.
SGLang pre-allocates a static GPU memory pool controlled by --mem-fraction-static for model weights and the RadixAttention KV cache. If other processes occupy VRAM, or activation and CUDA graph peaks exceed the remaining unreserved fraction, SGLang throws torch.OutOfMemoryError.
- Symptom
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 2.00 GiB in sglang- Root cause
- Static KV pool fraction (--mem-fraction-static), activation batch peak, or co-resident GPU usage exceeded physical GPU VRAM.
- Recommended fix
- Run nvidia-smi to ensure no stale Python/vLLM/SGLang workers occupy VRAM on the target GPUs.
- How Denpex helps
- Denpex investigates SGLang torch.OutOfMemoryError: CUDA out of memory using the evidence you provide or your connected workload collects. Earlier rank, host or application evidence is needed to distinguish an initiating failure from a downstream report.
What this failure is
A PyTorch CUDA allocation inside SGLang failed because weights, the static RadixCache pool, or runtime activations exceeded available GPU HBM.
Is this what broke your run? Paste your log.
You're reading about SGLang torch.OutOfMemoryError: CUDA out of memory. Paste your own traceback and relevant evidence for an investigation of your workload, with a next action or a specific missing fact. A reference entry does not establish your cause. No account or card for the free diagnosis. Review data handling before submitting sensitive logs.
Before uploading, review cloud data handling and local options.
Upload your log file. Large files are processed in your browser. Only selected evidence is submitted when you run diagnosis.
Why it happens (the mechanism)
Either --mem-fraction-static is too high leaving zero room for FlashInfer/CUDA graph/activation peaks, another process holds GPU memory on the same device, or incoming concurrent prefills exceed --chunked-prefill-size and --max-running-requests budgets.
What you'll observe
- SGLang crashes at startup or under load with torch.OutOfMemoryError: CUDA out of memory
- RadixAttention pool consumes GPU capacity leaving insufficient activation headroom
Common symptoms and what they mean
Check possible explanations against the incident evidence. A matching symptom alone does not establish its cause.
| Symptom | Possible explanation |
|---|---|
| torch.OutOfMemoryError: CUDA out of memory. Tried to allocate ... in sglang.srt | Static KV pool fraction (--mem-fraction-static), activation batch peak, or co-resident GPU usage exceeded physical GPU VRAM. |
| Memory pool initialization fails on rank during model or CUDA graph warmup | Static KV pool fraction (--mem-fraction-static), activation batch peak, or co-resident GPU usage exceeded physical GPU VRAM. |
Which systems are affected
- SGLang inference servers on NVIDIA GPUs
- Tensor-parallel and single-GPU SGLang deployments
How to confirm this is the problem
Use this checklist to test the hypothesis against a small reproduction. No single line proves the root cause, so preserve the preceding events and compare one variable at a time.
- ✓Verify clean startup through CUDA graph warmup and run representative concurrent prompts while monitoring /metrics cache usage.
Root cause
- Static KV pool fraction (--mem-fraction-static), activation batch peak, or co-resident GPU usage exceeded physical GPU VRAM.
The fix and how to prevent it
How to fix it
- Run nvidia-smi to ensure no stale Python/vLLM/SGLang workers occupy VRAM on the target GPUs.
- Lower --mem-fraction-static (for example from 0.88 down to 0.80 or 0.78) when OOM occurs during CUDA graph capture or forward activations.
- Cap concurrency and prefill peaks using --max-running-requests and --chunked-prefill-size, or test --disable-cuda-graph as a controlled isolation step.
- If model weights alone consume too much HBM, increase --tp or switch to FP8/AWQ weight quantization.
Step-by-step remediation
- 1Run nvidia-smi to ensure no competing GPU processes exist.
- 2Lower --mem-fraction-static from 0.88 to 0.80 and cap --max-running-requests.
- 3Replay peak prompt lengths and verify stable memory under load.
How to prevent it
- Load-test worst-case concurrent prompt lengths before deploying
- Reserve 12% to 20% HBM headroom outside --mem-fraction-static for FlashInfer workspaces and CUDA graphs
Save this diagnosis and catch the next crash automatically
All root cause, fix, and prevention steps above are free to read. Create a free account with any email or GitHub to keep your saved diagnosis history across the encyclopedia and run cloud checks, or use a work email below for the 30-day Team evaluation. No card required.
Or start a 30-day free Team trial (work email)
Verified work email unlocks all 14 fleet diagnostic tools, Slack alerts, and team history for 30 days. No card and no automatic charge.
Searchable error signature
torch.OutOfMemoryError: CUDA out of memory. Tried to allocate 2.00 GiB in sglang
RuntimeError: Not enough memory. Please lower --mem-fraction-static or --max-running-requestsUse this text as a lookup key in logs and upstream issue trackers. It is not presented as a captured customer log. Confirm the cause from your own preceding events, versions, configuration and the cited references.
Diagnose your own log automatically
The root cause and fix steps above stay free. Create a free account to analyze full job logs, attribute the first failed rank, and keep saved incident history.
Sign up free. Analyze your cluster logsNo credit card. Daily allowance follows verified trust tier. Instant access.
Why the recommended fix works
Lowering --mem-fraction-static returns HBM headroom to temporary PyTorch/FlashInfer activation buffers and CUDA graphs while capping --max-running-requests limits concurrent peak allocation.
Code examples
nvidia-smi
python3 -m sglang.launch_server --model-path YOUR_MODEL --tp 2 --mem-fraction-static 0.80 --max-running-requests 64This snippet illustrates the entry-specific check. Verify the installed versions, permissions, target and workload context before using it. A command or API example is not proof of recovery.
Best practices by model family
| Model / Stack | Recommendation | Notes |
|---|---|---|
| OOM during CUDA graph / warmup | Lower --mem-fraction-static to 0.78 to 0.82 | Frees headroom outside static RadixCache pool. |
| OOM mid-serving under spike | Lower --max-running-requests or --chunked-prefill-size | Caps activation memory during long prefills. |
With the fix vs without the fix
| Dimension | With the fix | Without the fix |
|---|---|---|
| Headroom tuning | Sized --mem-fraction-static + --chunked-prefill-size | Default 0.88+ collides with large batch activations |
| Process hygiene | Clean nvidia-smi check before server launch | Zombie worker leaves partial VRAM unavailable |
Diagnostic note
“Unlike PyTorch training where OOM shrinks batch size, in SGLang lowering --mem-fraction-static actually gives PyTorch/CUDA graphs MORE free memory outside the static KV pool when warmup crashes.”
Diagnose this failure in VS Code
Select the traceback or open the failed terminal, then run Denpex locally to inspect matched failure patterns, supporting evidence and next checks without uploading the log. Verify recommendations against your workload before changing production.
Install the free VS Code extensionSGLang errors in context
SGLang failures cross RadixAttention cache pools, FlashInfer kernels, and worker timeouts.
Compare related sglang errorsFrequently asked questions
Questions engineers and on-call staff commonly ask about this failure.
Should I raise or lower --mem-fraction-static on SGLang CUDA out of memory?
How does --chunked-prefill-size prevent SGLang OOMs?
Don't just read the fix, diagnose your run
The encyclopedia explains documented failure patterns. Denpex investigates your logs, configuration and stack, shows the supporting evidence, and asks for missing details when needed.
Related Inference errors
DeepGEMM rejects FP8 block-scaled weights with Unknown SF transformation on an unsupported architecture
Inference · high
SGLang NCCL Error and Multi-Node Timeout
Inference · high
vLLM NCCL P2P Hang and Timeout in Tensor Parallelism
Inference · high
vLLM CUDA Graph Capture OOM: Startup Fix & Tuning
Inference · high