Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversOctober DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsPC HealthRecommendedCrashes, freezes, slowdowns? Check your PC nowSpot repairable issues before they interrupt work.Check PC×
Skip to content
World desk5 min

What to Do When an LLM Runs Out of GPU Memory

An LLM CUDA out-of-memory error can come from weights, inference cache, training activations, or graph capture. Diagnose the failure phase before changing settings or hardware.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When an LLM hits a CUDA out-of-memory error, first identify what it was doing at the moment it failed. Loading model weights, allocating inference KV cache, training, and capturing CUDA graphs all have different memory demands—and different fixes. Check the error and GPU usage before changing settings; clearing the cache or buying a larger GPU may not address the actual cause.

Diagnose when and where the OOM occurs

Record the exact error message and the operation that failed. For a serving process, inspect startup logs to see whether the error occurs while loading weights, allocating the KV cache, or compiling and warming up CUDA graphs. NVIDIA treats these as distinct failure phases, so the timing helps narrow down the remedy.

As an Amazon Associate I earn from qualifying purchases.

Check total GPU memory and which processes are using it. Also distinguish memory actively allocated by your program from memory reserved by a framework allocator: PyTorch notes that unused memory held by its caching allocator can still appear as used in nvidia-smi. PyTorch’s memory profiler also cannot see every allocation; memory obtained directly through CUDA APIs or other libraries, including NCCL, may be outside its view.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Do not assume every OOM is fragmentation. If the model, cache, and workload genuinely need more memory than the GPU has, allocator settings cannot create additional VRAM. Fragmentation is worth investigating when the error and memory statistics show substantial reserved-but-unallocated memory or inactive split blocks.

#1 Best Overall
ASUS Dual Radeon RX 9060 XT 16GB GDDR6 Gaming Graphics Card | PCIe 5.0, HDMI 2.1b, DisplayPort 2.1a, 2.5-slot design, Axial-tech Fans, 0dB Technology
  • Axial-tech fans now feature a smaller fan hub that facilitates longer blades and a barrier ring that increases downward air pressure
  • 2.5-slot design allows for greater build compatibility while maintaining cooling performance
  • 0dB technology lets you enjoy light gaming in relative silence
  • Dual BIOS switch lets you toggle between Quiet and Performance BIOS profiles
  • Dual ball fan bearings last up to twice as long as sleeve bearing designs

If the model will not fit while loading

Estimate weight storage before changing hardware. NVIDIA’s rule of thumb is total parameters × bytes per parameter ÷ tensor parallelism. Its table assigns two bytes per parameter to BF16 and FP16, and one byte per parameter to FP8. This estimates weights only—not KV cache, activations, communication buffers, CUDA graphs, or other runtime overhead.

NVIDIA example Estimated weight memory What it means
8-billion-parameter Llama 3.1, BF16, one GPU 16 GB NVIDIA’s NIM guide says this example fits on a 24 GB GPU with room for KV cache and overhead. It is an example, not a guarantee for other runtimes or workloads.
70-billion-parameter Llama 3.3, BF16, four GPUs 35 GB per GPU Illustrates the estimated weight allocation when distributed across four GPUs.
70-billion-parameter Llama 3.3, FP8, two GPUs 35 GB per GPU Illustrates that a lower-precision format does not necessarily mean less memory per GPU when the GPU distribution also changes.

These are NVIDIA figures from its current NIM troubleshooting guide, accessed in 2026; they are estimated weight requirements, not independent benchmark results or universal hardware requirements. See NVIDIA’s GPU memory troubleshooting guide.

Rank #2
GIGABYTE GeForce RTX 5070 Ti Gaming OC 16G Graphics Card, 16GB 256-bit GDDR7, PCIe 5.0, WINDFORCE Cooling System, GV-N507TGAMING OC-16GD Video Card
  • Powered by the NVIDIA Blackwell architecture and DLSS 4
  • Powered by GeForce RTX 5070 Ti
  • Integrated with 16GB GDDR7 256bit memory interface
  • PCIe 5.0
  • WINDFORCE cooling system

If weights are the bottleneck, consider a supported lower-precision or quantized profile, distributing the model across more GPUs, or using a smaller model. Confirm that the exact model and serving runtime support the format and distribution you plan to use. Lower precision can affect output quality, and splitting a model across GPUs requires compatible hardware and runtime support.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

If inference runs out of memory after loading

Inference memory is not just model weights. The KV cache stores information used to generate tokens and grows with inference needs such as context length and concurrent requests. Review the serving stack’s context limit, batching or concurrency, and cache budget. Reducing these demands can lower live memory use, though it may limit how many requests or how much context the server can handle.

Rank #3
GIGABYTE GeForce RTX 5060 WINDFORCE OC 8G Graphics Card, Cooling System, 8GB 128-bit GDDR7, PCIe 5.0, Manufactured by NVIDIA, DisplayPort & HDMI - Video Output Interface, GV-N5060WF2OC-8GD Video Card
  • Powered by the NVIDIA Blackwell architecture and DLSS 4
  • Powered by GeForce RTX 5060
  • Integrated with 8GB GDDR7 128bit memory interface
  • PCIe 5.0
  • WINDFORCE cooling system

For NVIDIA NIM with vLLM, the --gpu-memory-utilization setting controls the budget for model operations; NVIDIA documents a default of 0.9. Check the documentation for your installed version before changing or copying a command, since this is a runtime-specific setting rather than a universal PyTorch option.

If logs show failure during KV-cache allocation alongside considerable reserved-but-unallocated memory, allocator fragmentation may be a factor. For the NIM/PyTorch context covered by NVIDIA, the guide documents PYTORCH_ALLOC_CONF=expandable_segments:True as a possible remedy. Use it only when the symptoms and runtime match; it is not a general fix for workloads that exceed physical capacity.

Rank #4
Sale
GIGABYTE Radeon RX 9070 XT Gaming OC 16G Graphics Card, PCIe 5.0, 16GB GDDR6, GV-R9070XTGAMING OC-16GD Video Card
  • Powered by Radeon RX 9070 XT
  • WINDFORCE Cooling System
  • Hawk Fan
  • Server-grade Thermal Conductive Gel
  • RGB Lighting

If training reaches its memory peak

Training often uses substantial memory for activations as well as weights. Reduce the micro-batch size or sequence length to reduce how much work is resident at once. If the training loop supports it, gradient accumulation can use smaller micro-batches while preserving a larger effective batch; check the framework’s loss scaling and optimizer-step behavior when changing it.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Activation checkpointing is another trade-off. It saves fewer intermediate activations and recomputes them during the backward pass, reducing activation memory at the cost of additional compute. PyTorch describes the technique in its guide to activation checkpointing.

Best Value
Sale
ASUS Prime Radeon RX 9070 XT 16GB GDDR6 OC Edition Gaming Graphics Card | PCIe 5.0, HDMI/DP 2.1, 2.5-slot, Axial-tech Fans, Dual-ball Fan Bearings, dual BIOS, ASUS GPU Guard
  • Axial-tech fans now feature a smaller fan hub that facilitates longer blades and a barrier ring that increases downward air pressure
  • Phase-change GPU thermal pad helps ensure optimal heat transfer, lowering GPU temperatures for enhanced performance and reliability
  • 2.5-slot design allows for greater build compatibility while maintaining cooling performance
  • Dual-ball fan bearings last up to twice as long as standard conventional sleeve bearings designs
  • 0dB technology lets you enjoy light gaming in relative silence
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

If CUDA graph capture or warmup fails

A serving process can load its model and allocate cache successfully, then run out of memory during graph capture or warmup because those stages need additional headroom. For NVIDIA NIM, the troubleshooting guide recommends lowering --gpu-memory-utilization to leave more memory unreserved, or disabling CUDA graphs with the NIM option or eager-mode flag documented for that runtime. Disabling graphs can reduce inference throughput. Do not apply NIM flags to another server or a general PyTorch setup without checking that runtime’s documentation.

What torch.cuda.empty_cache() does—and does not do

PyTorch says that torch.cuda.empty_cache() “Releases all unoccupied cached memory currently held by the caching allocator so that those can be used in other GPU applications and visible in nvidia-smi.” In other words, it releases unused cached blocks for other applications and can make memory reporting clearer; it does not increase the memory available to your active PyTorch workload.

If the active workload still needs more memory than is available, address live allocations instead: remove references to objects you no longer need and reduce model, cache, or workload demand. For details, see PyTorch’s CUDA semantics documentation and its CUDA memory usage guide.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

When a GPU with more VRAM makes sense

Consider a GPU upgrade if a supported smaller or lower-precision configuration, reduced context or concurrency, and workload tuning still cannot meet your needs. Match capacity to the whole workload: model weights, KV cache, activations, communication buffers, CUDA graphs, and runtime overhead. An 8B BF16 example fitting on a 24 GB GPU does not establish that 24 GB is sufficient for every model, server, or workload.

A “GPU with 24GB VRAM” is a capacity category, not a specific card recommendation. Before choosing a GPU, check its current price and availability, board dimensions, power requirements, cooling, compatibility, and fit for your intended model and runtime.

Quick Recap

Bestseller No. 1
ASUS Dual Radeon RX 9060 XT 16GB GDDR6 Gaming Graphics Card | PCIe 5.0, HDMI 2.1b, DisplayPort 2.1a, 2.5-slot design, Axial-tech Fans, 0dB Technology
ASUS Dual Radeon RX 9060 XT 16GB GDDR6 Gaming Graphics Card | PCIe 5.0, HDMI 2.1b, DisplayPort 2.1a, 2.5-slot design, Axial-tech Fans, 0dB Technology
0dB technology lets you enjoy light gaming in relative silence; Dual BIOS switch lets you toggle between Quiet and Performance BIOS profiles
$529.00
Bestseller No. 2
GIGABYTE GeForce RTX 5070 Ti Gaming OC 16G Graphics Card, 16GB 256-bit GDDR7, PCIe 5.0, WINDFORCE Cooling System, GV-N507TGAMING OC-16GD Video Card
GIGABYTE GeForce RTX 5070 Ti Gaming OC 16G Graphics Card, 16GB 256-bit GDDR7, PCIe 5.0, WINDFORCE Cooling System, GV-N507TGAMING OC-16GD Video Card
Powered by the NVIDIA Blackwell architecture and DLSS 4; Powered by GeForce RTX 5070 Ti; Integrated with 16GB GDDR7 256bit memory interface
$1,249.99
Bestseller No. 3
GIGABYTE GeForce RTX 5060 WINDFORCE OC 8G Graphics Card, Cooling System, 8GB 128-bit GDDR7, PCIe 5.0, Manufactured by NVIDIA, DisplayPort & HDMI - Video Output Interface, GV-N5060WF2OC-8GD Video Card
GIGABYTE GeForce RTX 5060 WINDFORCE OC 8G Graphics Card, Cooling System, 8GB 128-bit GDDR7, PCIe 5.0, Manufactured by NVIDIA, DisplayPort & HDMI - Video Output Interface, GV-N5060WF2OC-8GD Video Card
Powered by the NVIDIA Blackwell architecture and DLSS 4; Powered by GeForce RTX 5060; Integrated with 8GB GDDR7 128bit memory interface
$494.95
SaleBestseller No. 4
GIGABYTE Radeon RX 9070 XT Gaming OC 16G Graphics Card, PCIe 5.0, 16GB GDDR6, GV-R9070XTGAMING OC-16GD Video Card
GIGABYTE Radeon RX 9070 XT Gaming OC 16G Graphics Card, PCIe 5.0, 16GB GDDR6, GV-R9070XTGAMING OC-16GD Video Card
Powered by Radeon RX 9070 XT; WINDFORCE Cooling System; Hawk Fan; Server-grade Thermal Conductive Gel
$814.99
SaleBestseller No. 5
ASUS Prime Radeon RX 9070 XT 16GB GDDR6 OC Edition Gaming Graphics Card | PCIe 5.0, HDMI/DP 2.1, 2.5-slot, Axial-tech Fans, Dual-ball Fan Bearings, dual BIOS, ASUS GPU Guard
ASUS Prime Radeon RX 9070 XT 16GB GDDR6 OC Edition Gaming Graphics Card | PCIe 5.0, HDMI/DP 2.1, 2.5-slot, Axial-tech Fans, Dual-ball Fan Bearings, dual BIOS, ASUS GPU Guard
0dB technology lets you enjoy light gaming in relative silence; Dual BIOS switch lets you toggle between Quiet and Performance BIOS profiles
$831.99

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. World desk4 min
    How to Spot an AI Voice Scam Before Sending MoneyDon’t rely on how a caller sounds. Pause, call back through a known number, and verify the emergency with another trusted person before sending money.
  2. Mountain View desk4 min
    Google’s SynthID Detector: How to Check AI-Generated Images, Video and AudioGoogle’s SynthID Detector looks for an embedded watermark in supported images, video and audio. Here is what its results do—and do not—show.
  3. Redmond desk20 min
    How to create a link to File or Folder in Windows 11Windows 11 gives you several ways to point to a file or folder without moving or duplicating it. You can create a desktop shortcut,…
Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.