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

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

Most local-model failures have a predictable cause: the GPU must hold more than the model’s weight file. Weights, the key-value (KV) cache, activations, communication buffers, CUDA graphs, adapters and multimodal state all compete for the same VRAM. Classify the stage at which the run fails, verify that the runtime is actually using the GPU, then reduce the specific allocation that exceeds your headroom.

A model that loads and then crashes is usually running out of KV-cache or warm-up memory, not rejecting a defective model file. A model that generates slowly is often spilling layers to system RAM or oversubscribing CPU threads. The fixes below apply to llama.cpp, Ollama, LocalAI and LM Studio, with settings named for each where they differ.

What the error stage tells you

Read the log around the failure and identify when it happens. The stage narrows the cause before you change settings.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Failure stage Likely cause First change to try
Before or during weight loading Too many parameters, high-precision weights, insufficient VRAM, or inadequate tensor/pipeline parallelism Use a smaller model or lower-memory quantization; distribute layers across more GPUs
After weights load, during KV-cache or block allocation Context window is too large, KV cache is placed on the GPU, or memory is fragmented Lower context length and batch size; review KV-cache placement
CUDA graph capture or warm-up Only a small amount of VRAM remains for graph work and temporary buffers Lower the runtime memory budget or disable CUDA graphs for diagnosis
Generation starts but is slow CPU fallback, partial GPU offload, excessive threads, large context or batch settings Confirm GPU layers in logs, then tune offload, threads, context and batch size

Do not infer capacity from the model-file size alone. A quantized file may fit while its runtime allocations do not.

#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter | 4Pack Type C Female to A Male Cable Converter for Apple Duo 17 16 15 14 Plus,iWatch Watch 12 11 10,iPad 9 8 Air,Airpods 5 4
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

How much VRAM do you need?

Use NVIDIA’s planning heuristic as a lower bound for the weights:

weight_memory_per_gpu = total_parameters × bytes_per_parameter ÷ tensor_parallelism

Reserve additional memory for the KV cache, activations, communication buffers, CUDA graphs, adapters and any image or audio state. The usable budget is lower than the advertised VRAM capacity because the operating system, driver and other processes also need memory.

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

Worked sizing example

NVIDIA estimates that an 8-billion-parameter Llama 3.1 model in BF16 needs approximately 8 billion × 2 bytes = 16 GB for weights. Its documentation says that this can fit on one 24 GB GPU, such as an A10G or RTX 4090, with room left for KV cache and runtime overhead. That is a workload-dependent example, not a guarantee for every context length, batch size or backend.

Long contexts can consume the remaining headroom surprisingly quickly. A model’s native context setting, often read from max_position_embeddings in config.json, may demand more KV-cache memory than remains after weights, activations and overhead are subtracted.

Step 1: Confirm that acceleration is active

Before tuning performance, prove that the model is on the GPU. A CPU-only run can look like a memory problem while actually being a device-discovery or driver problem.

Rank #2
Sale
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter | USB C Dongle with 90W Max Power Delivery, 3×5Gbps USB A Data Ports, for MacBook, Dell, and More (Charger Not Included)
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.

llama.cpp

Start the model with GPU offload requested, for example:

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

llama-server --model model.gguf --n-gpu-layers 60

(The short form is -ngl 60.) In startup output, look for lines like llama_model_load_internal: [cublas] offloading 60 layers to GPU and llama_model_load_internal: [cublas] total VRAM used: 17223 MB. These diagnostics indicate that CUDA offload is active and show the allocation reported by the example run. If no layers are offloaded, check that you installed a CUDA-capable build and that the driver can see the GPU.

LocalAI

Use nvidia-smi while the model starts and verify that the process appears with GPU memory allocated. Use a CUDA-enabled container image, select the backend that matches the model format, and inspect logs for ggml_init_cublas: found X CUDA devices. A GGUF model should normally be paired with the llama-cpp backend. If the container cannot see the device, fix passthrough and driver configuration before changing quantization.

Ollama

For an Ollama installation in a container, verify NVIDIA device passthrough, the NVIDIA driver and Unified Virtual Memory (UVM). Enable diagnostic output with OLLAMA_DEBUG=1, then inspect the service log and kernel messages for device or driver errors. A missing GPU in these checks means the model is likely running on CPU regardless of its size.

LM Studio

Watch the load information for GPU offload and observe VRAM use in the operating system’s GPU monitor. The relevant controls are context_length, eval_batch_size, flash_attention and offload_kv_cache_to_gpu. Their effect depends on the backend and model, so change one at a time and monitor both memory and tokens per second.

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

Fix models that do not fit during weight loading

Choose a smaller quantization

Quantization stores weights with fewer bits, reducing memory at the cost of some numerical precision. If Q8_0 or Q6_K will not load, LocalAI specifically recommends trying Q4_K_S or Q2_K. Q4_K_S generally preserves more quality than Q2_K but uses more memory; Q2_K is a more aggressive capacity-first option. Compare variants of the same model at the same context and workload rather than assuming the highest-bit file is always best.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter | 85W Max PD, 2 USB 3.0 & 1 USBC Data Ports, SD/TF Card Reader, for Laptops/Mac and Other Type C Devices (Charger Not Included)
  • 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.

Choose fewer parameters

A smaller model can be faster and more reliable than a larger model that forces extensive CPU offload. Parameter count and quantization interact: reducing both may free enough VRAM for the KV cache and leave room for stable generation.

Distribute the model

When several GPUs are available, use tensor or pipeline parallelism so that each device holds only part of the weights. NVIDIA recommends distributing weights across more GPUs when the selected precision cannot fit on one device. Confirm from logs that the intended number of devices and layers is actually being used.

Do not treat system RAM as equivalent VRAM

Allowing layers to spill into system memory can make a run technically possible but dramatically slower because generation must cross the PCIe or interconnect boundary. If you must use partial offload, keep the GPU-resident layers that the runtime prioritizes and reduce context and batch allocations so the offload is deliberate rather than an emergency fallback.

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

Fix an out-of-memory error after the model loads

Lower the context length first

The KV cache grows with the number of tokens retained for attention. A model can finish loading and then fail when the first request allocates its cache. Set a smaller maximum context: use context_size in LocalAI, --max-model-len in runtimes that expose that option, or the equivalent application setting. NVIDIA’s example reduces --max-model-len to 4096 to fit a constrained GPU.

In LM Studio, context_length is the maximum number of tokens considered. Set it to the longest prompt and conversation you genuinely need, not automatically to the model’s advertised native maximum. If a 32K context is unnecessary, starting at 4K or 8K leaves substantially more room for generation and other allocations.

Reduce input and evaluation batch size

Batching processes more input tokens simultaneously and therefore needs more temporary memory. In LM Studio, lower eval_batch_size when prompt evaluation causes an OOM or a large transient spike. Other runtimes expose a similarly named batch or prompt-batch setting. A smaller batch may reduce prompt throughput while allowing the model to run consistently.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray | Data transfer & Fast charging for MacBook, iPhone 17/16/15, iPad, Samsung Galaxy, Apple Watch
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

Decide where the KV cache belongs

Keeping the KV cache on the GPU usually improves latency but consumes VRAM. If the weights fit yet the cache does not, move the cache to system memory when your backend supports it. LM Studio exposes offload_kv_cache_to_gpu; disabling it can avoid an OOM at the cost of slower generation. Conversely, if the cache is currently on the CPU and you have spare VRAM, enabling GPU placement can improve speed.

What’s actually slowing this PC down?

Pick the symptom - the matching free tool is one click away.

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

Use Flash Attention where supported

LM Studio’s flash_attention option can reduce memory use and improve speed on compatible backends and hardware. Enable it, retest the same prompt and context, and keep it disabled if the backend or driver does not support it correctly.

Handle fragmentation and CUDA-graph warm-up failures

Recognize fragmentation

A process can report substantial reserved but unallocated PyTorch memory and still fail a large allocation because free blocks are fragmented. NVIDIA documents this mitigation:

PYTORCH_ALLOC_CONF=expandable_segments:True

Set the variable before launching the service, then restart it. This changes allocator behavior; it does not create additional VRAM and cannot make an oversized model fit.

Give graph capture more headroom

Some runtimes allocate extra memory while capturing CUDA graphs or warming up. If the failure appears at that point, lower the runtime’s memory-utilization budget so temporary allocations have room, or disable CUDA graphs for diagnosis. Disabling graphs can reduce throughput, so use it to confirm the cause and then re-enable them if a lower budget resolves the issue.

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

Clear competing allocations

  • Stop other GPU applications, browsers using hardware acceleration and stale model servers.
  • Unload inactive models; a service that keeps several models resident can consume the headroom needed by the next request.
  • Restart the process after changing context, cache or allocator settings so old reservations are released.

Fix slow generation once the model runs

Check for partial CPU offload

Inspect the startup log for the number of GPU layers and total VRAM. If only part of the model is on the GPU, generation speed may be limited by repeated transfers to system RAM. Lower the model size or quantization, reduce context and batch allocations, or add GPU capacity so more layers remain resident.

Best Value
Sale
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display | 85W Max PD, 1 Powered USB-C 5Gbps & 2 Powered USB-A 3.0 5Gbps Data Ports, for MacBook Pro, MacBook Air, Dell and More (Black)
  • 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.

Tune CPU threads instead of maxing them out

More threads are not automatically faster. llama.cpp recommends starting with one thread, doubling the count until a bottleneck appears, then setting the production value around the physical-core count. An excessively large -t or --threads value can oversubscribe the CPU, increase contention and reduce tokens per second. Benchmark with a repeatable prompt after each change.

Reduce context and batch overhead

Every additional token in the active context increases attention work, and large prompt batches can make the initial evaluation phase dominate perceived latency. Trim old conversation turns, lower the maximum context, or reduce evaluation batch size when prompt processing—not token generation—is the slow phase.

Separate prompt speed from generation speed

Measure time to first token and steady-state tokens per second separately. A large prompt, image input or cold CUDA graph can make first-token latency high even when subsequent generation is fast. If both are slow, investigate device use and CPU offload first; if only the first token is slow, adjust context, batch and warm-up settings.

Free tools Windows power users keep installed

One-click scans. No signup required.

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

Tool-specific settings checklist

Runtime Settings and checks Typical use
llama.cpp -ngl/--n-gpu-layers; startup VRAM and offload lines; -t/--threads Request GPU layers, verify CUDA, then tune physical-core-aligned threading
LocalAI Matching backend and model format; context_size; lower quantization; low_vram; model unload limits Fit GGUF models, constrain cache use and prevent multiple resident models
LM Studio context_length, eval_batch_size, flash_attention, offload_kv_cache_to_gpu Balance cache placement, prompt throughput and VRAM
Ollama Container passthrough, current NVIDIA driver and UVM, OLLAMA_DEBUG=1, service and kernel logs Resolve GPU discovery and driver failures before performance tuning

A repeatable troubleshooting procedure

  1. Record the exact failure point. Note whether it occurs during weight load, cache allocation, graph capture, warm-up or generation.
  2. Observe the device. Run nvidia-smi during startup and save the runtime’s offload and VRAM lines.
  3. Make a conservative baseline. Use a short context such as 4096 tokens, a small evaluation batch, one CPU thread initially, and no other resident models.
  4. Fix capacity in order. If weights fail, lower parameter count or quantization, then add parallelism. If the cache fails, lower context and adjust KV placement. If warm-up fails, address fragmentation or graph headroom.
  5. Change one variable. Retest the same prompt and record memory, time to first token and steady-state tokens per second.
  6. Increase limits gradually. Raise context, batch size and thread count independently until the first regression, then keep the previous stable value.
  7. Persist only verified settings. Put the working values in the service configuration and document the model, quantization, driver and backend so an update can be diagnosed against a known baseline.

Common symptoms and targeted fixes

  • “Loads to 100%, then OOMs on the first prompt”: lower context length, reduce evaluation batch size and check KV-cache placement.
  • “Works at 2K context but fails at 16K”: the KV cache, not the weights, is exceeding the remaining VRAM; use a smaller context or move the cache off GPU.
  • “GPU utilization is near zero and CPU is busy”: inspect CUDA build, device passthrough, drivers and offload log lines.
  • “It runs, but tokens per second fell after increasing threads”: reduce --threads toward the physical-core count.
  • “Only graph capture fails”: lower the memory budget or disable CUDA graphs temporarily, and investigate fragmentation.
  • “A smaller quantization fixed OOM but quality changed”: move up one quantization level if headroom permits, or use a smaller parameter-count model at a higher precision.

Capacity planning that remains reliable

Plan for the complete runtime footprint rather than the model filename: weight memory plus KV cache, activations, communication buffers, graph allocations, adapters and multimodal state. Leave headroom for the driver and other processes. A 24 GB card can accommodate the documented 16 GB BF16 weight example with room for runtime allocations, but a longer context, larger batch, image input or multiple resident models can consume that margin.

For a stable deployment, record the model’s parameter count and quantization, GPU VRAM, context limit, KV-cache location, batch size, thread count, backend, driver version and whether parallelism is enabled. Those details explain why an identical model may succeed on one machine and fail or crawl on another.

Frequently Asked Questions

Why does a local model run out of memory after it has already loaded?

The KV cache and other runtime allocations are created after weight loading. Lower the context length first, then reduce batch size or move the KV cache off the GPU if your runtime supports it.

How can I tell whether Ollama or llama.cpp is using my GPU?

Watch nvidia-smi during startup and inspect logs. llama.cpp should report GPU-layer offload and total VRAM; Ollama and container deployments should show successful device passthrough and no UVM or driver errors.

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

Is a lower quantization always the best fix?

It is the direct fix for weight-capacity failures, but it trades precision for memory. Try the highest quantization that leaves room for the required context and runtime overhead; LocalAI lists Q4_K_S and Q2_K as lower-memory alternatives to Q8_0 and Q6_K.

Why is CPU offload so slow?

Each generation step may transfer data between GPU and system memory. Reduce model size or quantization, lower context and batch allocations, or add GPU capacity so more layers remain resident.

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.