iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
When an AI model runs out of VRAM, first identify whether the limit is model weights, the active context or batch, another process, a memory leak, or allocator fragmentation. For inference, work through this order: close competing processes, reduce context and concurrency, use a smaller or quantized model, verify memory-efficient attention, then try CPU offload. For training, fix leaks and fragmentation, reduce activation memory, reduce optimizer state with 8-bit optimizers or adapters, shard across GPUs, and only then move to a larger card. The right fix depends on which memory bucket is full; no single setting saves a universal percentage.
What does a CUDA out-of-memory error actually mean?
A CUDA out-of-memory (OOM) error means the next allocation could not be satisfied, not necessarily that the model weights alone are too large. Inference normally needs memory for weights, the key-value (KV) cache and framework overhead. Training adds gradients, optimizer state and saved activations. A model can fit at a short prompt and fail at a longer context, or appear to fit until another process, a leak or a temporary peak consumes the remaining VRAM.
Start by reading the PyTorch error. It reports the allocation requested, total capacity, currently free memory, memory allocated by PyTorch and memory reserved by PyTorch but not allocated. Nodus’ diagnostic guide uses those values as a decision tree:
Quick wins for a faster PC:
Repair Windows errors before they cause bigger problemsFix Now →Scan for outdated or missing drivers - takes under a minuteDriver Scan →- Allocated memory is close to capacity: live tensors do not fit. Reduce the workload or model.
- Several gigabytes are reserved but unallocated: fragmentation may be preventing a contiguous block.
- Free memory is nearly zero while PyTorch’s allocated and reserved values are small: another process owns the VRAM.
nvidia-smi shows memory held by the CUDA allocator as used, including reusable cached blocks. In PyTorch, torch.cuda.memory_allocated() is live tensor memory, while torch.cuda.memory_reserved() includes the caching allocator. Check peak values because a temporary spike can trigger OOM even when the model looks smaller afterward.
Popular on Amazon
- 【90 Degree Full Function USB C Adapter】Supports the latest USB4 standard for up to 40Gbps of bandwidth, 8K video support, and up to 240W Fast charging; Support USB PD 3.1 Extended Power Range (EPR) including 140W, 180W and 240W. Your productivity is easily doubled. *Warm Tip: For the best fit, please make sure the USB-C port is fully exposed; thick or bulky cases may affect compatibility.
- 【Reliable Quality】Made from high-quality, scratch-resistant aluminum alloy, delicate metal frame. get excellent wear resistance and heat dissipation. Non-Slip Design for easier insertion and removal.
- 【Small and portable】Ultra thin size, ultra compact design, a petite physique that matches the minimalist design of your modern laptops. Coming with a slim figure that won't block the port next to the one it's plugged into.
- 【Compatibility】Widely work with most usb c, thunderbolt 4/3 devices. Compatibilit for ROG Ally, Steam Deck, Switch, MacBook Pro, Quest 3 VR headset, Surface Book 2, iPhone 18/17/16/15, Samsung Galaxy S23/S22/S21, Note 20/10, Google Pixel, ChromeBook, etc.
- 【Excellence Customer Support】If you experience any issues or cable failure, simply reach out to our dedicated customer service team. We provide a prompt response within 18 hours, providing you with the necessary technical support to resolve any concerns.
How do I find the process or allocation that is using VRAM?
Measure the same workload before changing settings. This prevents a saving reported for one model or context from being mistaken for a guarantee on another.
- Run
nvidia-smiand note every process using the GPU. Close an abandoned notebook, server, game, browser tab or second model process before tuning the model. - In PyTorch, print live and reserved memory at the point of failure:
print(torch.cuda.memory_allocated() / 2**30, 'GiB allocated')
print(torch.cuda.memory_reserved() / 2**30, 'GiB reserved')
print(torch.cuda.get_device_properties(0).total_memory / 2**30, 'GiB capacity')
- Measure the peak around one complete step. This catches temporary activation or optimizer spikes:
torch.cuda.reset_peak_memory_stats()
# forward
# backward
# optimizer.step()
optimizer.zero_grad(set_to_none=True)
print(torch.cuda.max_memory_allocated() / 2**30, 'GiB peak allocated')
print(torch.cuda.max_memory_reserved() / 2**30, 'GiB peak reserved')
- If an OOM appears only after hours, inspect retained tensors. A line such as
total_loss += losskeeps each step’s computation graph alive; usetotal_loss += float(loss). Do not append GPU tensors to logging lists unless you detach and move them to CPU. - Use
torch.inference_mode()for evaluation and generation that does not require gradients. If a retry is inside anexceptblock, delete references to the failed tensors before retrying; the exception frame can keep them alive.
For a line-by-line allocation trace, PyTorch can record allocator history with torch.cuda.memory._record_memory_history() and write a snapshot. Run the longest expected sequence first: activation memory rises with sequence length, and an eager attention matrix grows approximately with the square of that length.
What should I change first for local inference?
For a local model that fails during generation, use this sequence: remove competing GPU work, shorten the context or lower concurrency, choose a smaller or quantized checkpoint, confirm efficient attention, then offload only what cannot fit. This order follows the practical ladder summarized by MacMyths’ local-AI guidance.
1. Close competing applications
Stop other model servers and orphaned Python processes. The PyTorch FAQ example cited by Nodus suggests checking for leftovers with:
ps -elf | grep python
In a long-running service, make sure one worker is not loading a second copy of the model. Container and desktop processes can also share the same GPU.
2. Reduce context, batch size and concurrency
Lower the maximum context window, prompt length, batch size or number of simultaneous requests. A shorter context reduces the KV cache; a smaller batch reduces active tensors and, during training, activations. Change one setting at a time and repeat the same prompt or batch so the effect is attributable.
3. Empty the cache only for other applications
torch.cuda.empty_cache() releases unused cached blocks to other programs. It does not free live tensors and does not make a model that does not fit suddenly fit inside PyTorch. Use it after deleting tensors or between independent jobs, not as a substitute for reducing the workload.
Do these 3 things before closing this tab:
1Scan for outdated or missing drivers - takes under a minute2Repair Windows errors before they cause bigger problems3Fix the driver behind crashes, sound loss and screen glitches4. Fix fragmentation when reserved memory is much larger than allocated memory
Set the current allocator option before CUDA initializes:
export PYTORCH_ALLOC_CONF=expandable_segments:True
PYTORCH_CUDA_ALLOC_CONF is the backward-compatible alias still printed in some error messages and older posts. The option is experimental and helps when changing sequence or batch sizes leaves unusable memory slivers; it does not reduce the model’s true footprint.
Also popular on Amazon
- 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
- Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
- Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
- HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
- What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.
How much VRAM do model weights require?
The first estimate is parameter count multiplied by bytes per parameter. CloudFleet’s 2026 table gives these approximate weight sizes:
| Precision | Bytes per parameter | 8B model | 70B model |
|---|---|---|---|
| FP16 or BF16 | 2 | 16 GB | 140 GB |
| FP8 or INT8 | 1 | 8 GB | 70 GB |
| INT4 or FP4 | 0.5 | 4 GB | 35 GB |
Real checkpoint files are slightly larger because quantized formats store scales and some embeddings, output layers or sensitive layers remain at higher precision. For example, Nodus calculates 16.1 GB for the 8,030,261,248 parameters in Llama 3.1 8B at 16-bit.
Mixture-of-experts models are another trap: active parameters determine compute, but total parameters determine stored weights. Qwen3-30B-A3B activates about 3.3 billion parameters per token but has about 30.5 billion total, so BF16 weights are roughly 61 GB. A sparse model can therefore be inexpensive to compute yet large to load.
How much memory does the KV cache use?
The KV cache grows with layers, KV heads, head dimension, context length and concurrent requests. A useful estimate is:
KV bytes per token = 2 * layers * KV heads * head dimension * bytes per value
Total KV memory = KV bytes per token * context tokens * concurrent requests
The factor of two is for keys and values. Read num_hidden_layers, num_key_value_heads and head_dim from the model configuration. Do not substitute the total attention-head count when the model uses grouped-query attention.
| Model | Layers | KV heads | Head dimension | FP16 KV per token |
|---|---|---|---|---|
| Llama 3.1 8B | 32 | 8 | 128 | 128 KiB |
| Llama 3.1 70B | 80 | 8 | 128 | 320 KiB |
| Qwen3-30B-A3B | 48 | 4 | 128 | 96 KiB |
These figures are from CloudFleet’s 2026 calculations. An 8-bit KV cache halves them. For Llama 3.1 70B, incorrectly using 64 attention heads instead of eight KV heads produces 2.5 MiB per token instead of 320 KiB.
Sixteen simultaneous Llama 3.1 8B conversations at 8,192 tokens represent 131,072 cached tokens. At 128 KiB per token, that is about 16 GiB of KV cache in addition to 16 GB of BF16 weights. A model that works for one short chat can therefore fail under concurrency. vLLM’s current documentation sets --gpu-memory-utilization to 0.92 by default; leave additional room for CUDA graphs, activations and the CUDA context.
Practical KV reductions are straightforward: lower the context limit, lower concurrent requests or batch size, and enable a supported 8-bit cache. In vLLM, the cache type is selected with --kv-cache-dtype. In llama.cpp-style runtimes, q8_0 key and value caches are common options.
Which quantization format should I use on my GPU?
The GPU generation and serving engine determine which format is useful. DeployGPU’s format matrix summarizes the compatibility:
Also popular on Amazon
- Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
- Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
- Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
- Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
- What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.
| Format | Ampere | Ada | Hopper | Blackwell |
|---|---|---|---|---|
| INT4 weights (AWQ, GPTQ) | Yes | Yes | Yes | Yes |
| FP8 weights and activations | Weight-only | Native | Native | Native |
| NVFP4 or MXFP4 | Weight-only fallback | Weight-only fallback | Weight-only fallback | Native |
| GGUF in vLLM | Experimental | Experimental | Experimental | Not listed |
- vLLM on Ada or Hopper: use an official FP8 checkpoint when available; native FP8 arithmetic can reduce weights to about half of BF16.
- vLLM on Ampere: AWQ or GPTQ 4-bit weights are usually more appropriate. FP8 is weight-only there and may use a 16-bit compute path.
- vLLM on Blackwell: use NVFP4 or MXFP4 when a compatible checkpoint exists; otherwise use FP8.
- llama.cpp or Ollama: start with a GGUF Q4_K_M file, or Q8_0 when memory allows.
Q4_K_M is about 4.89 bits per weight in llama.cpp’s Llama 3.1 8B table. Other listed sizes are Q5_K_M at 5.70 bits, Q6_K at 6.56, Q8_0 at 8.50, Q3_K_M at 4.00 and Q2_K at 3.16. Quantization below 4 bits can cause substantial quality loss, and some quantized layers can run slower. Choose the lowest format that leaves room for the actual KV cache, then validate it on the prompts important to you.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Do not requantize an already quantized file if you can avoid it. The llama.cpp guidance cited by DeployGPU warns that a second quantization can severely reduce quality; start from the 16-bit or 32-bit source and use an importance matrix when appropriate. Ollama imports GGUF but does not quantize it during import. vLLM can quantize linear and mixture-of-experts weights at load time, but downloading the unquantized checkpoint still requires the larger disk and transfer budget.
Can a 70B model run on a 24GB GPU?
Not fully on the GPU for a dense 70B model. The arithmetic puts INT4 or FP4 weights near 35 GB before cache, while DeployGPU lists a 43 GB Q4_K_M Llama 3.3 70B file. A 24 GB card cannot hold those weights alone. A 48 GB card may load the 43 GB file, but leaves almost no room for a useful cache; an 80 GB card is the practical single-GPU target for a fully resident 4-bit 70B.
CPU offload can make a 70B run by keeping part of the model in system RAM, but it does not make the weights disappear. Every token crosses the CPU-GPU connection for offloaded layers, so generation can be dramatically slower. A claim that a fully on-GPU 4-bit 70B needs only about 20 GB conflicts with both parameter arithmetic and published file sizes.
How do I reduce memory during training or fine-tuning?
Training fails for different reasons than inference. Fix leaks and fragmentation first, then reduce activations, then optimizer and model-state memory. Nodus’ Llama 3.1 8B example illustrates the scale for one 4,096-token sequence:
Recommended Free Tools
| Bucket | Estimate |
|---|---|
| 16-bit weights | 16.1 GB |
| Gradients plus AdamW | 112.4 GB |
| Fused-attention activations | 18.3 GB |
| FP32 output logits | 2.1 GB |
| Total | 148.8 GB |
Mixed-precision Adam is commonly estimated at about 16 bytes per parameter: 2 bytes for weights, 2 for gradients and 12 for FP32 master weights plus the two Adam moments. That is roughly 128 GB for an 8B model before activations. Mixed precision therefore does not remove optimizer-state memory.
Enable memory-efficient attention
PyTorch scaled-dot-product attention can dispatch to a fused, memory-efficient kernel, but dispatch depends on hardware, masks, head dimensions and software version. Calling SDPA does not guarantee that the most memory-efficient path is active.
Nodus’ arithmetic for Llama 3.1 8B at 4,096 tokens estimates 18.3 GB of fused-attention activations versus 104.2 GB when the eager attention matrix is retained. If your loader exposes an attention implementation, select SDPA or FlashAttention before changing model precision. Confirm the selected kernel in your framework’s logs.
Use micro-batch 1 and gradient accumulation
When a full batch does not fit, use the largest micro-batch that does—often one sequence—and accumulate gradients over several steps. Eight micro-batches of one preserve an effective batch of eight while avoiding the approximately 146 GB of fused activations that an eight-sequence micro-batch could require. Batch-dependent layers such as BatchNorm still see the micro-batch, so accumulation is not mathematically identical for every architecture.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Also popular on Amazon
- Portable and powerful USB-C HUB: BENFEI USB Type-C HUB, with super-soft and knot-free silicone woven design cable, meets most mobile office needs. Compact, lightweight, stylish, and powerful portable USB C Hub equipped with 1 x HDMI port, 1 x 100W charging, and 3 x USB ports. 18-month warranty, 24-hour response, to ensure you feel at ease when using our product.
- Design centered on comfort and reliability: Thanks to BENFEI's end-to-end in-house cable production capability, in-house PCBA and assembly capability, using the industry's most advanced silicone woven design and process, 20cm cable in length, no knots, super-soft, the HUB is easy to use in all scenarios: laptop, tablet, stand etc. Super-soft, 25000+ life cycles, to meet your daily carrying and office needs.
- 100W Charging: Support up to 90W USB C pass-through charging via Type-C port to keep your laptop powered. 10W is reserved for other interface operations. No data and video function on the Type-C port.
- 4K HDMI Display: The HDMI port supports media display at resolutions up to 4K 30Hz, keeping every incredible moment detailed and ultra vivid. Please note that the C port of the Host device needs to support video output.
- Transfer Files in Seconds: Transfer files and from your laptop at speeds up to 10 Gbps with USB A 3.2 port. Extra 2 USB A 2.0 ports are perfectly for your keyboards and mouse.
Turn on activation checkpointing
Activation checkpointing stores layer inputs and recomputes the rest during backpropagation. In the Nodus example, stored activations fall from 18.3 GB to about 1.1 GB. The trade-off is compute: the Korthikanti measurement cited there found roughly 30–40% more execution time with full recomputation. Checkpointing does not reduce weights, gradients or Adam states.
In torchtune, the relevant setting is enable_activation_checkpointing=True. Activation offloading to CPU is an additional measure and should be combined with checkpointing rather than used instead of it.
Use an 8-bit optimizer when full fine-tuning is required
8-bit Adam stores moment statistics in one byte instead of four. Nodus estimates that its 8B example falls to about 83.5 GB after checkpointing, still above an 80 GB card. Paged 8-bit optimizers can spill state to CPU when the GPU is short, while other implementations trade a little more VRAM for speed. Lower-precision optimizer states can affect numerical stability, so monitor loss and checkpoint frequently.
Use LoRA or QLoRA when the base model need not change
LoRA freezes the base weights and trains small low-rank matrices. For rank 16 on every linear layer in the Llama 3.1 8B example, Nodus estimates 41.9 million trainable parameters, about 0.7 GB for their gradients and optimizer state, and about 19.9 GB for the complete run. Typical ranks range from 8 to 256; adding adapters to MLP and output layers can improve adaptation at a memory cost. Tied embeddings in some models do not support a separate LoRA on the tied output.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchQLoRA keeps the frozen base in 4-bit NF4 and trains LoRA adapters. torchtune summarizes the saving as roughly 1.5 bytes per model parameter relative to a 16-bit frozen base, while noting that quantized weights are upcast for computation and therefore QLoRA is slower than LoRA. Nodus estimates about 7.9 GB for the 8B example, with extra room needed in practice because embeddings and output layers often remain at 16-bit. The QLoRA paper demonstrated fine-tuning a 65B model on one 48 GB GPU, but that result is tied to its method and workload, not a universal capacity rule.
Shard full fine-tuning across GPUs
If every weight must train, use a sharded strategy rather than forcing all state onto one card. Nodus estimates that fully sharded data parallelism divides the approximately 16 bytes per parameter across GPUs; eight GPUs would hold about 19.2 GB each before all-gather buffers. The current PyTorch API it names is fully_shard. Tensor parallelism suits a model that fits on one multi-GPU node; pipeline parallelism is useful across nodes or on systems without fast NVLink, although PCIe-only scaling is weaker.
When is CPU offload the right choice?
CPU offload is a capacity escape hatch, not usually the first performance optimization. It can start an otherwise impossible run, but host RAM and PCIe or interconnect traffic become bottlenecks.
For training, DeepSpeed’s ZeRO-Offload tutorial describes moving optimizer memory and computation to the host and demonstrates a 10-billion-parameter model on one 32 GB GPU with activation checkpointing and ZeRO stage 2. The same tutorial says DeepSpeedCPUAdam is 5–7 times faster than the standard PyTorch implementation in its cited comparison; that is the tutorial’s result, not a guarantee for every system.
torchtune advises using CPU-offload optimizers only after other techniques. The torchao guidance it quotes warns that host RAM can rise by about four times the model size because parameters are copied and gradient memory is preallocated. With gradient offloading enabled, gradient accumulation may need to remain at one. Expect the CPU step to dominate unless the workload leaves enough GPU work to hide it.
Also popular on Amazon
- 【Read before You Buy】 Note: This adapter is USB 2.0 version and cannot transmit HDM, VGA, or other video signals. Nevertheless, they are fully capable of charging devices,duplicating files, and can be seamlessly integrated with USB-C earphones, wireless network adapters, and SD card adapters.
- 【Easy to Use and Safe】Thanks to modern manufacturing techniques, we've made these adapters sufficiently compact so that they can remain inserted in your device without noticeable protrusion or inconvenience. This means you don't have to constantly plug and unplug them, reducing the likelihood of wear and misalignment, and making them more convenient to carry around.
- 【Reliable Quality】Engineered for enhanced durability, durable aluminum alloy shell material,get excellent wear resistance and heat dissipation,the male USB C and female USB connectors & the male USB and female USB C connectors are designed to be plugged and unplugged up to 20000 times. Provides data transfer, device charging, memory space expansion, and additional computer peripherals.
- 【Think more for you】Do you need to connect a USB-C-enabled device to an odd device that only has USB-A ports? Then these USB-A male to USB-C female adapters are made for you.Simply insert the adapter into the USB-A port on the device, and you can instantly connect your USB-C device to the device that originally didn't have the correct connection port.
- 【Trusted xiwxi Quality and Service】As a responsible brand seller, you will receive xiwxi's 12-month Quality assurance and lifetime friendly customer service, you're not just buying a product,you're investing in peace of mind with all-round quality and exceptional customer service.
For inference, lower the number of GPU layers in llama.cpp, use the runtime’s GPU-offload slider, or let a supported server place some experts or layers in RAM. A quantized model that fits entirely on the GPU is normally much faster than a larger model that crosses the bus for every token. One 16 GB spot-check reported by the DEV Community article saw a Q4_K_M model using 9.3 GB and generating 34.7 tokens/s, while partial offload of an FP16 model used 14.9 GB and generated 4.1–7.6 tokens/s. Those are one author’s measurements, not a benchmark you should generalize.
What does a larger GPU need to hold?
Only upgrade after the arithmetic still exceeds the software-adjusted requirement. CloudFleet lists these memory capacities per GPU (checked in its 2026 material):
| GPU | Memory per GPU |
|---|---|
| L4 | 24 GB |
| L40S | 48 GB |
| A100 | 40 or 80 GB |
| H100 | 80 GB SXM or 94 GB NVL |
| RTX PRO 6000 Blackwell | 96 GB |
| H200 | 141 GB |
| B200 | 180 GB in CloudFleet’s NVIDIA-cited table; another 2026 marketplace listing gives 192 GB |
| B300 | Up to 288 GB, depending on system |
For the Llama 3.1 8B estimates, Nodus’ cloud list (prices checked November 14, 2026) places QLoRA’s 7.9 GB need on a 16 GB RTX A4000 at $0.173 per hour, LoRA’s 19.9 GB on a 24 GB RTX 3090 at $0.180 per hour, an 83.5 GB full fine-tune with 8-bit Adam on a 96 GB RTX PRO 6000 at $1.350 per hour, and a 131.7 GB checkpointed AdamW run on a 180 GB B200 at $5.500 per hour. These are cloud rates, not retail card prices, and they exclude runtime differences. The same source considers 141 GB on an H200 too tight for the last estimate because headroom is only about 7%.
Free tools Windows power users keep installed
One-click scans. No signup required.
How should I choose between quantization and offload?
Compare the option against the memory bucket it changes, not just the headline VRAM number.
| Option | Reduces | Main trade-off | Best use |
|---|---|---|---|
| Shorter context or lower concurrency | KV cache and active tensors | Less memory and fewer simultaneous tokens | Inference OOM under long prompts or load |
| Weight quantization | Model weights | Possible quality or speed change; engine compatibility | A model that is too large to load |
| KV-cache quantization | KV cache | Potential output-quality change | Long context or many concurrent requests |
| Efficient attention | Attention intermediates | Kernel dispatch limitations | Training or inference with long sequences |
| Checkpointing | Saved activations | About 30–40% more recomputation time in one cited measurement | Training activation OOM |
| 8-bit optimizer | Optimizer states | Possible stability and speed trade-offs | Full fine-tuning near the memory limit |
| LoRA or QLoRA | Trainable state and, for QLoRA, frozen weights | Adapter-based training; QLoRA is slower than LoRA | Task adaptation without updating every weight |
| CPU offload | GPU-resident weights or optimizer state | Host RAM use and much lower speed | Making an otherwise impossible job run |
| More or larger GPUs | Per-device capacity through sharding | Hardware and interconnect cost | Full models or full fine-tunes that still do not fit |
Published savings are setup-specific. MacMyths relays separate PyTorch Foundation results of 73% lower peak VRAM for one quantized-KV 128K inference setup, 30% lower peak VRAM for a 4-bit optimizer training setup and 97% faster inference for an autoquant weight-only setup. Those percentages describe different models and workloads; they are not interchangeable forecasts.
What is the shortest reliable recovery checklist?
- Record the exact model, precision, context, batch, concurrency and GPU capacity.
- Run
nvidia-smi; stop competing processes. - Compare
memory_allocated(),memory_reserved()and peak values. - Fix graph leaks, retained logging tensors and evaluation without inference mode.
- If reserved-but-unallocated memory is large, set
PYTORCH_ALLOC_CONF=expandable_segments:Truebefore startup. - For inference, reduce context, batch or concurrency; then choose a smaller or quantized model.
- Enable an actually supported efficient-attention kernel and, where appropriate, an 8-bit KV cache.
- For training, use micro-batch 1, accumulation, BF16 or FP16 autocast, checkpointing and then an 8-bit optimizer.
- If all weights do not need updating, use LoRA or QLoRA; if they do, shard with FSDP or another distributed strategy.
- Use CPU offload only when its speed and RAM cost are acceptable. Upgrade or rent a larger GPU when the arithmetic still does not fit.
Frequently Asked Questions
Why does nvidia-smi show more VRAM used than torch.cuda.memory_allocated()?
The CUDA caching allocator keeps reusable blocks reserved, and nvidia-smi counts those blocks as used. Compare both allocated and reserved values, plus peak allocation, rather than treating the nvidia-smi number as live tensor memory.
Does lowering batch size reduce an LLM’s KV cache?
It reduces the number of sequences cached at once, so total KV memory falls with batch or concurrency. It does not change the per-token cache cost of one sequence; lowering the context limit is what shortens that sequence’s cache.
Free tools Windows power users keep installed
One-click scans. No signup required.
Is BF16 always smaller than FP16?
Both BF16 and FP16 use two bytes per parameter, so their weight memory is essentially the same. BF16 can be easier to train on supported hardware because it normally does not require the gradient scaler used with FP16 autocast.
How much system RAM should I add for CPU offload?
The required amount depends on what is offloaded and whether gradients or optimizer copies are duplicated. torchtune’s cited torchao guidance warns that host RAM can reach roughly four times the model size, so calculate for the complete offloaded state rather than adding only the GPU shortfall.
Can I use a quantized checkpoint in every inference engine?
No. GGUF is common in llama.cpp-style runtimes, while AWQ, GPTQ and FP8 support varies by server and GPU generation. Check that the engine has a native or supported kernel; a format that loads through a fallback path may use less memory but run slower.

