GPU memory fragmentation can block a local AI model when free capacity is split into regions that cannot satisfy the runtime’s next allocation pattern.
The failure often appears after switching models, changing context lengths, running image and language workloads together, or serving requests whose temporary tensors grow and shrink. Monitoring may show unused VRAM, yet the allocator still cannot place a large workspace, model shard, or KV cache expansion without releasing or reorganizing existing blocks. The sections below separate true capacity shortage from allocator fragmentation and explain why restarting the runtime can temporarily make the same model fit again.
Total Free VRAM Is Not the Same as Usable Allocation Space
A memory monitor reports aggregate capacity, but an allocator must satisfy requests through the blocks and virtual mappings it manages. Several small free regions may add up to more than the requested size while still being unusable under a contiguous allocation rule.
An LLM operations analysis describes this free-memory mismatch when KV caches and variable tensors leave holes smaller than the next request. The visible OOM is therefore about layout as well as total bytes.
Drivers and frameworks may also report device-free, reserved, allocated, and inactive memory differently. Compare the runtime allocator’s view with device-level usage instead of trusting one headline number.
Changing Tensor Sizes Create Holes Over Time
AI workloads repeatedly allocate and release tensors of different sizes for prompts, batches, image dimensions, attention workspaces, and temporary conversions. A caching allocator keeps blocks for reuse because repeatedly returning them to the driver is expensive.
GMLake research shows that irregular allocations can degrade splitting-based memory pools and create substantial fragmentation in large models. Reusing exact sizes is efficient; repeatedly splitting and merging mismatched sizes is harder.
A model-switching home server is especially vulnerable because language, diffusion, vision, and speech runtimes request very different block shapes from the same GPU.
Fragmentation can accumulate without a memory leak. Every allocation may eventually be released to the pool, yet the pool’s shape may remain poorly matched to the next workload.
Growing KV Cache Makes Inference Fragmentation Dynamic
LLM weights are relatively stable after loading, while KV cache grows with active users, prompt length, and generated tokens. Requests also finish at different times, freeing uneven regions.
PagedAttention was designed to reduce KV cache fragmentation by storing request state in smaller blocks rather than reserving one large contiguous region for an unknown final sequence length.
This problem is different from fragmentation in the framework’s general tensor allocator, but both can coexist. A paged KV manager cannot automatically compact model workspaces or allocations owned by another process.
ZimaSpace’s discussion of concurrent contexts shows why a model that fits for one user can cross a memory boundary when several conversations expand simultaneously.
Reserved Memory Can Make the Failure Look Like a Leak
Framework allocators often retain freed blocks to speed later requests. Device tools count those blocks as used by the process even when the current model does not hold active tensors in all of them.
A practical OOM guide separates reserved memory from active model and cache requirements. A large gap can indicate reusable allocator blocks, fragmentation, or a workload whose peak was higher than its present state.
Clearing a cache may return some blocks to the driver, but it cannot free live weights, active KV state, another process’s context, or a workspace required by the next operation.
Stable Allocation Shapes and Paging Reduce Repeat Failures
Reproduce the failure with one model, fixed context limit, fixed batch size, and no competing AI services. Log process-level allocated and reserved memory, device-level free memory, largest request, and the workload sequence that preceded the OOM.
vAttention uses virtual memory mapping to separate contiguous virtual KV space from physical allocation. Similar paging and segmented-allocation approaches reduce dependence on one physically continuous region.
For a home server, practical controls include leaving VRAM headroom, limiting model switching, using stable context and batch ceilings, coordinating services through one runtime, and restarting a fragmented process during maintenance rather than after a user request fails.
If a clean restart does not make the model fit, the primary problem is likely real capacity rather than accumulated fragmentation. Reduce model size, quantization footprint, context, batch, or competing allocations.
Tech & AI HUB
More to Read

Why Do Smart Home Predictions Become Less Accurate After Seasonal Routine Changes?
Seasonal routines change the relationship between time, sensors, occupancy, and desired actions, making a model trained on older habits stale.

Why Does a Home NVR Miss Brief Events When Object Tracking Is Enabled?
Tracking needs enough detections to start and confirm a trajectory, so a brief object can disappear before the NVR creates a valid event.

Why Do AI Photo Labels Change After a Model Upgrade?
A model upgrade changes the representation and ranking used to assign labels, so the same photo can cross different semantic or confidence boundaries.

