Halloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowHalloween DealsAmazon USOctober picks are moving - compare before checkoutAmazon US: current deals, useful picks and tech finds.See Picks×
FREEDOM251

Freedom251 › Blog › CUDA

Why a Local Model Runs Out of Memory—and How to Fix It

By Freedom251 Team · · 5 min read

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

A local model runs out of memory when its weights and the rest of its runtime allocations exceed available GPU memory (VRAM) or system RAM. The fix depends on when the failure happens: while loading weights, allocating the context cache, warming up the runtime, or handling multiple requests. Identify that stage first; reducing context helps some failures, but cannot fix every memory shortage.

What uses memory in a local model?

Model weights are the baseline, not the entire memory budget. In addition to weights, a runtime may need memory for the key-value (KV) cache that holds context, temporary activations, drivers and runtime overhead, communication buffers, adapters, and simultaneous requests. GPU memory can be consumed by other applications, too.

As an Amazon Associate I earn from qualifying purchases.

NVIDIA estimates weight memory from parameter count, bytes per parameter, and how weights are distributed across GPUs. Its example gives an 8-billion-parameter model in BF16 as 16 GB of weights on one GPU (8 billion × 2 bytes). NVIDIA says that example can fit on a 24 GB GPU with room for KV cache and overhead; it is an estimate, not a guarantee that every model or runtime configuration will fit. NVIDIA’s memory troubleshooting guide treats weights, KV cache, activations, and overhead as separate parts of the budget.

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

Context and concurrency change the budget after loading. Ollama defines context length as the number of tokens the model can access in memory; increasing it increases memory use. Its FAQ says memory for parallel requests scales with OLLAMA_NUM_PARALLEL × OLLAMA_CONTEXT_LENGTH. Multiple loaded models also compete for available GPU memory when they are kept resident for simultaneous use. See Ollama’s context-length documentation and Ollama’s FAQ.

#1 Best Overall
AMD Ryzen™ AI Halo - Personal AI Desktop Computer - Developer Platform - Linux OS
  • Built for Local AI Development: AMD Ryzen AI Halo is designed for local AI development and inference, featuring 128GB unified memory and support for up to 200B parameter models to build and run intensive AI workloads locally.
  • 128GB Unified Memory: Features 128GB LPDDR5x unified memory at 8000 MT/s with 256 GB/s memory bandwidth, providing a shared memory pool across the CPU, GPU, and NPU to support larger AI models.
  • AMD Ryzen AI Max+ 395 Processor: Features 16 cores, 32 threads, and Zen 5 architecture, paired with AMD Radeon 8060S integrated graphics featuring 40 RDNA 3.5 compute units and an AMD XDNA 2 NPU with up to 50 TOPS.
  • Linux AI Developer Platform: Purpose-built for Linux-based AI development with full AMD ROCm software support and preloaded tools, models, and workflows optimized for local AI development.
  • Compact, Connected Design: Includes a 2TB M.2 SSD, 10GbE LAN, Wi-Fi 7, Bluetooth 5.4, USB-C connectivity, and HDMI 2.1b.

Find the stage where the failure occurs

Read the runtime’s startup output and error around the failed allocation. “Out of memory” is a symptom, not a diagnosis: a weight-load failure, context-cache allocation, allocator fragmentation, and graph warm-up can need different remedies. NVIDIA recommends using startup diagnostics to identify the allocation phase rather than treating all CUDA errors alike. NVIDIA’s troubleshooting guide describes these distinct cases.

When it fails Likely cause First response
Before loading finishes Weights at the chosen precision, or the selected hardware/profile configuration, exceed capacity. Check model, precision, profile, and GPU placement; consider a smaller model, lower-memory supported format, or supported multi-GPU execution.
After weights load, during KV-cache allocation The configured context needs more cache than remains after weights and other allocations. Reduce context to the workload’s actual input-plus-output needs.
During cache allocation, with substantial reserved but unallocated PyTorch memory Allocator fragmentation may prevent a large contiguous allocation despite apparently sufficient aggregate free memory. Check the runtime’s allocator guidance; NVIDIA documents an allocator setting for this PyTorch situation.
During graph capture or warm-up There may not be enough headroom for initialization or graph allocations. Use the runtime-specific diagnostics to test a lower cache budget or disabled CUDA graphs, if supported.
Only with parallel requests or several loaded models Combined context, concurrency, and resident models exceed capacity. Stop idle models, reduce request parallelism, or lower context.
Only for one model or runtime Unsupported hardware/profile or a backend-specific issue may be involved, rather than a simple capacity shortage. Check the model and profile’s runtime support and inspect logs before changing hardware.

Fix the problem in order

  1. Record the configuration and error

    Note the model, weight precision or quantization, context length, number of parallel requests and loaded models, GPU and free VRAM, runtime version, and the relevant log lines. In Ollama, run ollama ps to see loaded model size, processor placement, and context. NVIDIA NIM prints memory diagnostics at INFO or DEBUG log levels. Ollama’s FAQ and NVIDIA’s guide describe these diagnostics.

    Rank #2
    Sale
    GMKtec X3 AI Mini PC AMD Ryzen Al Max+ 395 128GB LPDDR5X 2TB PCIe 4.0 SSD | OCuLink Gaming Mini Computer 16C/32T, Turbo 5.1GHz, 126 TOPS, 8000MHz Radeon 8060S 8K Display, WiFi 7 2.5G LAN, USB4 EVO-X3
    • Unlock next-generation AI computing with AMD Ryzen AI Max+ 395 processor featuring 16 cores, 32 threads, up to 5.1GHz boost clock, and integrated Ryzen AI engine delivering up to 126 TOPS AI performance. EVO-X3 is designed for local AI models, content creation, development, and professional workloads.
    • OCuLink External GPU Expansion – Upgrade Beyond a Mini PC: Take your graphics performance further with a dedicated OCuLink (PCIe 4.0 x4) interface. Connect an external GPU dock to add desktop-class graphics power for AAA gaming, AI acceleration, 3D rendering, video production, and advanced creative applications. EVO-X3 gives you the flexibility of a compact PC with workstation-level expansion capability.
    • AI NPU with XDNA 2 ARCHITECTURE - Powered by 16 “Zen 5” CPU cores, 50+ peak AI TOPS XDNA 2 NPU and a truly massive integrated GPU driven by 40 AMD RDNA 3.5 CUs, the Ryzen AI MAX+ 395 is a transformative upgrade and delivers a significant performance boost over the competition. The Ryzen AI Max+ 395 excels in consumer AI workloads like the llama.cpp-powered application: LM Studio. Shaping up to be the must-have app for client LLM workloads, LM Studio allows users to locally run the latest language model without any technical knowledge required and unleash their creativity and productivity.
    • AMD RADEON 8090S iGPU GAMING PC - The AMD Radeon RX 8060S offers all 40 CUs with up to 2.9 GHz graphics clock and uses the new RDNA 3.5 architecture. The powerful iGPU is positioned between an RTX 4060 and 4070 laptop GPU and therefore enables gaming in FHD at maximum details in most demanding games. The 8060S can also utilize the full 128GB pool, which is perfect for running LLMs such as Deepseek 70B Q8, which runs comfortably on this machine.
    • EIGHT CHANNEL LPDDR5X - LPDDR5X is a new ground breaking memory small form factor installed on-board. With blazing speeds up to to 8000MT/s, it runs 1.5x faster than the DDR5 SODIMMs; 90% better performance over DDR5 SODIMMs in video conferencing and photo editing; 30% better performance in productivity apps; 12% better performance in digital content workloads.
  2. Reduce context to what the task needs

    Context includes the prompt and generated tokens, so leave enough room for both, but do not allocate a much larger window than the task requires. In Ollama, adjust context in the application settings or with OLLAMA_CONTEXT_LENGTH; in an interactive ollama run session, use /set parameter num_ctx. In llama.cpp, set --ctx-size or -c. NVIDIA’s DGX Spark playbook gives lowering the value, for example to 4096, as a startup-OOM remedy; that is a configuration example, not a universal recommendation. Ollama context documentation · NVIDIA DGX Spark llama.cpp playbook

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

    Stop an idle Ollama model with ollama stop <model>, reduce parallel request count, or avoid keeping multiple models loaded when they do not need to serve at once. Ollama models can remain loaded for a default period; its FAQ documents parallel memory scaling with context and concurrency. Ollama FAQ

    Rank #3
    MINISFORUM MS-S1 MAX Mini AI Workstation PC, AMD Ryzen AI Max+ 395 (16C/32T),RDNA3.5 GPU,128GB LPDDR5x RAM 2TB SSMINI PC, Dual M.2 PCIe 4.0,PCIe x16 Slot, USB4 V2(80Gbps)& Dual 10GbE, 320W PSU,Wi-Fi 7
    • 【High-Performance APU】The MS-S1 MAX features an AMD Ryzen AI Max+ 395 APU, integrating a Zen 5 architecture CPU (up to 5.1GHz, 16C/32T, 64M L3 Cache), an RDNA 3.5 GPU, and an NPU (50 TOPS). The total system output is 126 TOPS. It provides powerful parallel computing capabilities for demanding AI workflows. It is ideal for running local LLMs, multimodal models, and computationally intensive tasks
    • 【128GB UMA Memory】Equipped with up to 128GB of LPDDR5x-8000MT/s unified memory, it enables the CPU and GPU to access a shared, high-bandwidth memory pool with extremely low latency. Ideal for large-scale AI inference, 3D workloads, and complex timelines in video editing. It eliminates traditional VRAM bottlenecks, ensuring smoother data transfer during high-intensity computations. The UMA design maximizes performance stability under high loads
    • 【Flexible Expansion】The MS-S1 MAX features USB4 V2 (up to 80Gbps), dual 10GbE LAN, HDMI 2.1 (up to 8K60), a full-length PCIe x16 expansion slot, and dual M.2 slots supporting up to 16TB RAID 0/1. Wi-Fi 7 provides stronger signal coverage and a more stable wireless experience. The slide-out design facilitates upgrades and maintenance. It easily adapts to personal, studio, or rack-mount enterprise environments
    • 【High-Efficiency Cooling System】Utilizing an aerospace-grade aluminum alloy chassis, copper base plate, six heat pipes, dual turbine fans, and advanced PCM thermal conductive material, it maintains stable cooling performance even under continuous load. This system supports 130W continuous power and 160W peak power operation, with a built-in 320W power supply. It boasts multiple global certifications including CCC, FCC, UL, CE, and UKCA, ensuring stable and reliable operation in various environments
    • 【Cluster Design】Two MS-S1 MAX units can be configured as a dual-unit cluster to run a large 235B Q4 model locally, achieving an output speed of 10.87 tok/s. Supporting 2U rack deployment, multiple MS-S1 MAX units can be cascaded into a distributed cluster to create a high-efficiency AI computing center. A cluster of four MS-S1 MAX units successfully ran a DeepSeek-R1 671B Q4 large model. A reserved cluster power-on interface allows for unified start-up and shutdown
  4. Use smaller or lower-memory weights if loading fails

    Choose a smaller parameter-count model or a lower-precision/quantized format supported by the model and runtime. Lower-memory weights may alter output quality, speed, or hardware support, so compare the actual model-format options rather than assuming all quantizations behave alike. NVIDIA notes that hardware support for a precision can affect performance. NVIDIA memory troubleshooting guide

  5. Reduce KV-cache use where supported

    Ollama documents Flash Attention as a way to significantly reduce memory use as context grows, and documents quantized K/V cache options when Flash Attention is enabled. Its FAQ estimates that q8_0 uses about half the memory of f16 with very small precision loss; q4_0 uses about one quarter, with small-to-medium precision loss that may be more noticeable at higher context. These are Ollama’s estimates, not guaranteed results for every model or task. Ollama FAQ

    Rank #4
    MINISFORUM MS-S1 Max Mini Workstation AMD Ryzen AI Max+ 395(16C/32T) 64GB LPDDR5 2TB SSD Mini PC, HDMI+2X USB4+2X USB4 V2 Video Output, 2x10G RJ45 Port, WiFi7, BT5.4, Radeon 8060S Graphics Computer
    • 【Leading AI Mini Workstation】MINISFORUM AI MS-S1 Max Workstation comes with AMD Ryzen AI Max+ 395 processor, which uses AMD's latest generation Zen 5 architecture. It has 16 Cores and 32 Threads, the boost clock is up to 5.1GHz. The overall processor performance is up to 126 TOPS, and the NPU performance reaches up to 50 TOPS. AMD Ryzen AI enables improved productivity, advanced collaboration, and improved efficiency.
    • 【AMD Radeon 8060S Graphics 】The MS-S1 Max Mini PC equipped with AMD Radeon 8060S Graphics which built on the new generation of RDNA 3.5 architecture AMD graphics, it brings ultra-high frame rate experiences and advanced content creation features anywhere and delivers staggering performance. It can handle all your computing and multimedia tasks efficiently.
    • 【Five 8K Video Output】This MS-S1 Max Workstation comes with five video outputs, 1x HDMI (8K@60Hz), 2x USB4(40Gbps,Alt DP2.0,PD out 15W) and 2x USB4 V2(80Gbps,Alt DP2.0,PD out 15W) Outputs, which support multiple monitors display at the same time and provide a larger and wider filed of view and improve your work efficiency. It is used in fields that require high-performance computing and graphics processing, including digital signage and securities trading, as well as work that uses CAD, such as engineering design, scientific calculations, animation production, and post-production for movies and television
    • 【 Fast and Stable Wire & Wireless Speed】It comes with Two 10G Lan Ports for wired connection and and Wi-Fi 7 / BT5.4 for wireless connection, which increased the network speed greatly and expand its functions and improved performance of computer to a large extent and allows you to use more networks such as software routers (OpenWRT / DD-WRT / Tomato etc.), firewalls, NAT, network isolation etc.
    • 【Large Storage & Flexible Expandability】This Workstation equipped with 64GB LPDDR5-8000MHz + 2TB M.2 2280 PCIe4.0 SSD. There is another PCIe4.0 SSD slot available for up to 8TB, these SSD slots are compatible with RAID0 and RAID1, you can store movies, videos, photos, important files easily. What’s more, it also comes with 1x standard PCIex16 slot(PCIe4.0x4) inside.
  6. Investigate allocator and warm-up failures separately

    For the described PyTorch fragmentation case, NVIDIA documents PYTORCH_ALLOC_CONF=expandable_segments:True as a possible mitigation. This changes allocator behavior; it does not add physical memory, and compatibility should be checked where CUDA allocations are shared. For NIM/vLLM graph-capture or warm-up shortages, NVIDIA describes reducing the KV-cache budget or disabling CUDA graphs as diagnostic options. Such graph changes can reduce throughput, and the example settings in that guide are not universal values. NVIDIA troubleshooting guide

    Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
  7. Consider offload or hardware only after checking placement and budget

    CPU offload may make a model runnable when GPU memory is insufficient, but can reduce performance. Use ollama ps to inspect placement; Ollama’s context guide advises avoiding CPU offload for performance where possible. If the model weights and required runtime allocations still cannot fit, more VRAM or supported multi-GPU execution may be necessary. Confirm the exact model, precision, context, and other memory users before choosing hardware. Ollama context documentation · NVIDIA troubleshooting guide

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

How to compare configurations or upgrades

Compare the whole workload, not just parameter count or a GPU’s advertised VRAM. A useful comparison includes:

  • Memory required by the chosen model at its actual weight precision or quantization.
  • Usable context for the prompt and output, plus any cache-format choices.
  • Quality and speed trade-offs from lower precision, quantized cache, or CPU offload.
  • Supported GPU count, model placement, and runtime/backend support.
  • Memory for activations, runtime overhead, adapters, other applications, and concurrent requests.

NVIDIA’s weight estimate can help establish a baseline, but its guide identifies KV cache, activations, and overhead as additional allocations. A 24 GB VRAM GPU is relevant only if the complete configuration fits; advertised VRAM alone does not establish that it will. NVIDIA memory troubleshooting guide

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.

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

CUDALarge Language Modelslocal AIOllamaTroubleshootingVRAM

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.

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.