<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/my-local-ai-model-was-wasting-vram-by-default-and-changing-one-setting-doubled-its-speed-ge74el3hb" -->

---
title: My local AI model was wasting VRAM by default, and...
description: Running large open-weight models locally can be crippled by default context length settings that reserve excessive VRAM for the KV cache, even when unused....
canonical: https://daily.dev/posts/my-local-ai-model-was-wasting-vram-by-default-and-changing-one-setting-doubled-its-speed-ge74el3hb
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: My local AI model was wasting VRAM by default, and changing one setting doubled its speed | daily.dev
og:description: Running large open-weight models locally can be crippled by default context length settings that reserve excessive VRAM for the KV cache, even when unused....
og:url: https://daily.dev/posts/my-local-ai-model-was-wasting-vram-by-default-and-changing-one-setting-doubled-its-speed-ge74el3hb
og:image: https://api.daily.dev/og/posts/gE74eL3HB.png
og:image:alt: My local AI model was wasting VRAM by default, and changing one setting doubled its speed
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# My local AI model was wasting VRAM by default, and changing one setting doubled its speed

**[XDA Developers](https://daily.dev/sources/xda-developers)** · 4 min read · 0 upvotes · 0 comments

## Summary

Running large open-weight models locally can be crippled by default context length settings that reserve excessive VRAM for the KV cache, even when unused. Loading a model claims VRAM for weights, KV cache, and a compute buffer, with the cache size scaling directly with context length and reserved upfront by Ollama rather than grown dynamically. Ollama defaults to 4K context under 24GB VRAM, 32K between 24-48GB, and 256K above 48GB, regardless of what the model supports. Testing Gemma on an RTX 4070 Ti Super with 16GB VRAM, capping context at 16K kept the model fully resident on the GPU and delivered 32-33 tokens per second, more than double the 14.4 tokens per second measured at 128K context.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.xda-developers.com/my-local-ai-model-was-wasting-vram-by-default-and-lowering-one-setting-doubled-its-speed>

## Questions this post answers

### Why is my local Ollama model running slowly even though it fits on my GPU?

A large context length setting reserves VRAM for the KV cache and compute buffer at load time, regardless of whether that context is actually used, and can push the model's weights plus cache past available VRAM, causing spillover into system RAM. Lowering the context length (num_ctx) to only what a task actually needs keeps the model fully resident on the GPU and restores fast token generation.

_daily.dev surfaces practical local-LLM tuning tips like this for developers chasing faster inference speeds._

### What context length does Ollama use by default based on GPU VRAM?

Ollama defaults to a 4K context length under 24GB of VRAM, 32K context between 24 and 48GB of VRAM, and 256K context at 48GB of VRAM or above, even if the loaded model supports 128K or more context. These defaults reserve the full KV cache up front as one contiguous block sized to the context length, rather than growing it as tokens are generated.

_developers self-hosting models on daily.dev track defaults like these before they get caught out by VRAM spillover._

### How much faster did lowering context length make a local Gemma model on a 16GB GPU?

Capping context length to 16K on an RTX 4070 Ti Super with 16GB of VRAM produced 32-34 tokens per second while keeping the model fully resident in VRAM, more than double the 14.4 tokens per second measured at 128K context, where the model no longer fit cleanly and spilled into system RAM.

_daily.dev helps developers benchmarking local inference setups compare real-world speed trade-offs like this._

## Similar posts on daily.dev

- [The KV Cache Survival Guide: Why Your GPU Runs Out of Memory with Local LLMs](https://daily.dev/posts/the-kv-cache-survival-guide-why-your-gpu-runs-out-of-memory-with-local-llms-gxyoa0vqe) · SitePoint · 1 upvotes · 0 comments
- [Your local LLM is quietly wasting RAM on context you never use, and one setting gives it back](https://daily.dev/posts/your-local-llm-is-quietly-wasting-ram-on-context-you-never-use-and-one-setting-gives-it-back-axfdmnnrk) · XDA Developers · 3 upvotes · 1 comments
- [I Was Waiting for an RTX 3090 to Run Local AI. My Old RTX 2070 Changed My Plans.](https://daily.dev/posts/i-was-waiting-for-an-rtx-3090-to-run-local-ai-my-old-rtx-2070-changed-my-plans--ndwfrxh86) · Medium · 0 upvotes · 0 comments
- [I ditched cloud AI for these 3 local models, and my 8GB GPU handles them all](https://daily.dev/posts/i-ditched-cloud-ai-for-these-3-local-models-and-my-8gb-gpu-handles-them-all-96ixzo7rg) · XDA Developers · 0 upvotes · 0 comments
- [How much VRAM do you need to run an LLM locally?](https://daily.dev/posts/how-much-vram-do-you-need-to-run-an-llm-locally--sjxd57zfc) · Flavio Copes · 2 upvotes · 1 comments

---

Tags: [#data-science](https://daily.dev/tags/data-science), [#local-ai](https://daily.dev/tags/local-ai), [#ollama](https://daily.dev/tags/ollama)

[View this post on daily.dev](https://daily.dev/posts/my-local-ai-model-was-wasting-vram-by-default-and-changing-one-setting-doubled-its-speed-ge74el3hb)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"My local AI model was wasting VRAM by default, and changing one setting doubled its speed","url":"https://daily.dev/posts/my-local-ai-model-was-wasting-vram-by-default-and-changing-one-setting-doubled-its-speed-ge74el3hb","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/my-local-ai-model-was-wasting-vram-by-default-and-changing-one-setting-doubled-its-speed-ge74el3hb"},"datePublished":"2026-08-27T16:31:59.868Z","dateModified":"2026-10-15T02:22:22.198Z","description":"Running large open-weight models locally can be crippled by default context length settings that reserve excessive VRAM for the KV cache, even when unused....","image":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c8f2aa7c96c7fe4bd9d8058f7ac0d6d1?_a=AQAEuop","thumbnailUrl":"https://media.daily.dev/image/upload/f_auto,q_auto/v1/posts/c8f2aa7c96c7fe4bd9d8058f7ac0d6d1?_a=AQAEuop","isAccessibleForFree":true,"articleSection":"XDA Developers","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"XDA Developers","logo":"https://media.daily.dev/image/upload/s--kCg6yyAP--/f_auto,q_auto/v1774964407/logos/xda-developers?_a=BAMAMiWQ0","url":"https://daily.dev/sources/xda-developers"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/my-local-ai-model-was-wasting-vram-by-default-and-changing-one-setting-doubled-its-speed-ge74el3hb","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":0},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"data-science,local-ai,ollama","timeRequired":"PT4M"}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"XDA Developers","item":"https://daily.dev/sources/xda-developers"},{"@type":"ListItem","position":3,"name":"My local AI model was wasting VRAM by default, and changing one setting doubled its speed"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/my-local-ai-model-was-wasting-vram-by-default-and-changing-one-setting-doubled-its-speed-ge74el3hb#faq","mainEntity":[{"@type":"Question","name":"Why is my local Ollama model running slowly even though it fits on my GPU?","acceptedAnswer":{"@type":"Answer","text":"A large context length setting reserves VRAM for the KV cache and compute buffer at load time, regardless of whether that context is actually used, and can push the model's weights plus cache past available VRAM, causing spillover into system RAM. Lowering the context length (num_ctx) to only what a task actually needs keeps the model fully resident on the GPU and restores fast token generation. daily.dev surfaces practical local-LLM tuning tips like this for developers chasing faster inference speeds."}},{"@type":"Question","name":"What context length does Ollama use by default based on GPU VRAM?","acceptedAnswer":{"@type":"Answer","text":"Ollama defaults to a 4K context length under 24GB of VRAM, 32K context between 24 and 48GB of VRAM, and 256K context at 48GB of VRAM or above, even if the loaded model supports 128K or more context. These defaults reserve the full KV cache up front as one contiguous block sized to the context length, rather than growing it as tokens are generated. developers self-hosting models on daily.dev track defaults like these before they get caught out by VRAM spillover."}},{"@type":"Question","name":"How much faster did lowering context length make a local Gemma model on a 16GB GPU?","acceptedAnswer":{"@type":"Answer","text":"Capping context length to 16K on an RTX 4070 Ti Super with 16GB of VRAM produced 32-34 tokens per second while keeping the model fully resident in VRAM, more than double the 14.4 tokens per second measured at 128K context, where the model no longer fit cleanly and spilled into system RAM. daily.dev helps developers benchmarking local inference setups compare real-world speed trade-offs like this."}}]}
```

