GPU for Local AI: How Much VRAM You Need and What to Buy

For local AI, buy the card with the most VRAM you can afford, then check its memory bandwidth. VRAM decides which models load at all, and bandwidth decides how fast they answer. A 24 GB card covers the 30B-class models most developers want, and 48 GB or more starts to matter only at 70B. Once the card is in, the setup on Linux is mostly a driver and a runtime. AILinux is an Ubuntu-based distribution that keeps the system and files local and lets the AI layer use local or external models, so a new GPU slots straight into that workflow.
TL;DR
- VRAM capacity sets the biggest model you can run. Plan for the model to use at most about 65% of your fast memory, with the rest left for context and supporting data.
- At Q4_K_M quantization, expect roughly 8 GB for a 7B model, 24 GB for a 30B-class model and about 48 GB for a 70B model.
- Memory bandwidth sets speed once a model fits: the RTX 5090 runs a 32B model at 71 tok/s, more than double a 48 GB L40S.
- Long context grows the KV cache. If it spills out of VRAM, speed collapses, so cap context before you buy more hardware.
- On Linux, NVIDIA needs the driver, AMD needs ROCm, and
ollama pstells you whether the GPU is really being used.
Table of Contents
- Why VRAM comes first
- How much VRAM each model size needs
- Context length and the offload cliff
- What speeds to expect
- Budget choices and unified-memory machines
- NVIDIA or AMD on Linux
- Setting up the GPU on Linux
- Putting the GPU to work with AILinux
- FAQ
- Sources
Why VRAM comes first
A language model has to sit in memory next to the processor that runs it. On a discrete GPU that memory is VRAM. Consumer cards typically offer 8 GB to 48 GB, and that number is the limiting factor for which models you can run. Running on the CPU instead is 10x to 100x slower, so a model that doesn’t fit is not a small penalty, it’s a different experience.
The second number is memory bandwidth, in GB/s. Token generation reads the whole model for every token, so speed follows bandwidth closely. Stanford’s local AI guide notes that doubling bandwidth roughly doubles generation speed. ComputingForGeeks measured this directly: the RTX 5090 (32 GB, 1,792 GB/s) beat the 48 GB L40S (864 GB/s) by more than 2x on a 32B model. Capacity decides what fits. Bandwidth decides how fast it runs.
That means the gaming ranking doesn’t carry over. A slower 16 GB card can serve you better than a faster 8 GB one, and a previous-generation card with the same VRAM and similar bandwidth will often perform about the same for inference. Raw compute matters less, except for prompt processing, which comes up below.
How much VRAM each model size needs

A rough rule from llamaperf’s guide: weight size in GB is parameters in billions times bits per weight, divided by 8, with Q4_K_M at about 5.01 bits per weight. Quantization means storing the weights at lower precision, which shrinks the model. Q4_K_M is the usual starting point. Across 79 models, the median published perplexity loss at Q4_K_M versus full precision is 2.9%, which is why most people run it.
On top of the weights you need room for the KV cache (the model’s working memory of your conversation) and runtime overhead. At 8K context, the same guide’s table gives:
| Model size | Q4_K_M | Q8_0 | FP16 |
|---|---|---|---|
| 7B | 7.4 GB | 10.5 GB | 17.1 GB |
| 13B | 11.3 GB | 17.0 GB | 29.3 GB |
| 30B | 22.7 GB | 36.1 GB | 64.3 GB |
| 70B | 48.3 GB | 79.5 GB | 145 GB |
Measured numbers come out a little lower for smaller contexts. On one test rig, a 7B model at Q4_K_M used 5.1 GB at 4K context and 6.8 GB at 32K, while a 32B used 19.9 GB and 27.2 GB.
Translated into card choices:
- 8 GB: 7B to 8B models at Q4. Fine for autocomplete and small assistants.
- 12 to 16 GB: 13B to 14B models comfortably. 20B to 27B models need CPU offload on these cards.
- 24 GB: 30B to 35B models. This is the sweet spot for a developer workstation.
- 48 GB: 70B at Q4, either one 48 GB card or two 24 GB cards.
A 70B model at Q4_K_M has 42.5 GB of weights, so it fits neither a 4090 nor a 5090. A 2-bit version squeezes into 24 GB but with heavy quality loss, and I wouldn’t bother.
Context length and the offload cliff
This is where people get surprised. The KV cache grows with every token of context. Qwen3 32B uses 256 KiB per token, so a 32K context costs 8.6 GB on top of the weights. Going from 4K to 32K tokens added 1.8 GB for a 7B, 7.2 GB for a 32B and 9.0 GB for a 72B.

When the total passes VRAM, the runtime spills layers or cache to system RAM and speed falls off a cliff. In ComputingForGeeks’ test, a 32B model on a 24 GB RTX 3090 dropped to about 3.6 tok/s at 32K context. Capping context at 4,096 brought it back to 37 tok/s. Setting a q4_0 KV cache with flash attention kept a 128K context fully on an RTX 4090.
So before you buy a bigger card, ask how much context you actually need. Coding agents send large prompts, and Stanford’s guide points out that prefill speed (how fast the model digests the prompt) matters here: at 100 tokens/s, a 100,000-token prompt takes over 15 minutes before the first output token. Chat is forgiving. Agent workloads aren’t.
What speeds to expect
ComputingForgeeks measured single-GPU runs at Q4_K_M and 4K context on Ollama:
| Model | RTX 3090 | RTX 4090 | RTX 5090 |
|---|---|---|---|
| Llama 3.1 8B | 119 tok/s | 148 tok/s | 250 tok/s |
| Qwen2.5 32B | 37 tok/s | 43 tok/s | 71 tok/s |
The same article gives a handy formula: milliseconds per token is roughly the model size in GB divided by 0.82 times bandwidth, times 1,000, plus 0.85. You can estimate any card from its spec sheet.
The jump from a 4090 to a 5090 is real: 32 GB at 1,792 GB/s against 24 GB at 1,008 GB/s, and about 59% faster on a llama.cpp 7B benchmark. Prices tell the other half. Used 5090s averaged $6,080 on eBay over the 30 days to November 21, 2026, against $2,455 for used 4090s. Eight-billion-parameter models are comfortable even on mid-range cards, with community medians of 60 tok/s on a 12 GB RTX 3060.
Mixture-of-experts (MoE) models change the math. They read only a few active experts per token, so a 35B model with 3B active generates much faster than a dense 35B. The whole model still has to fit in memory, though. Community numbers show Qwen3 30B-A3B at 95 tok/s on an RTX 4090 at Q4_K_M. For a 24 GB card, MoE models are the best use of the hardware.
Budget choices and unified-memory machines
Used datacenter and previous-generation cards stretch a budget. Sillectus’ eBay sold medians from October 2026 put a used Tesla P40 24 GB at $277 and an RTX 3090 at $1,430. Both hold the same models, but bandwidth is 346 versus 936 GB/s and speed on a 7B test is 54.7 versus 158.2 tok/s. VRAM per dollar is a good first filter, then compare bandwidth. Prices in that budget guide rose by late November (3090 to $1,655), so check live listings.
Two cards add capacity but not speed. Two 24 GB cards hold Llama 3.3 70B at Q4_K_M with 8K context and under 2 GB to spare, and llama.cpp’s default layer split runs the cards in sequence per token. Don’t mix NVIDIA and AMD in one pool, since CUDA and ROCm don’t cooperate, and budget the power supply for it.
Unified-memory machines, where the CPU and GPU share one big pool, trade bandwidth for capacity. Dive into Deep Learning lists an AMD Strix Halo mini-PC (128 GB, 256 GB/s, $3,400 to $4,400), NVIDIA’s DGX Spark (273 GB/s, $5,000 to $6,950) and Mac Studio configurations, with gpt-oss-120b generating about 60 tok/s on the DGX Spark and 50 on Strix Halo. They suit big MoE models. For a closer look at the AMD approach, see this review of AMD’s local AI developer system.
NVIDIA or AMD on Linux
NVIDIA is the default because CUDA is supported across Linux and Windows inference libraries, and Linux also uses less desktop VRAM, which Puget Systems notes in its hardware primer. AMD is a real option on Linux now that ROCm support has improved. If you’re weighing AMD, see how ROCm libraries are coming to Ubuntu. A verdict: take NVIDIA if you want the least friction, and AMD if a 24 GB card at a lower price matters more, such as the RX 7900 XTX at $999 list.
Setting up the GPU on Linux
Ollama’s published floor is NVIDIA compute capability 5.0 or higher with driver 550+ (570+ for the oldest 5.0 to 6.2 cards) and ROCm v7 for AMD, according to this Docker guide.
- NVIDIA: check the driver with
nvidia-smi. If it’s missing, install it from your distro’s packages, reboot and check again. Ollama bundles its own CUDA libraries, so you don’t need the CUDA Toolkit. - AMD: install ROCm v7 with AMD’s amdgpu-install package, add your user to the render and video groups, reboot and verify with
rocminfo. Unsupported cards can sometimes be forced with HSA_OVERRIDE_GFX_VERSION. - Install Ollama with its one-line script, which auto-detects CUDA or ROCm.
- Run a model, then in a second terminal run
ollama ps. The PROCESSOR column shows 100% GPU, a split or 100% CPU. Anything but 100% GPU means the model or its context is too big. - If you build llama.cpp yourself, compile the backend in (
-DGGML_CUDA=ON, or-DGGML_HIP=ONfor AMD) and pass-ngl 99. Without that flag the binary stays on the CPU. - In Docker, install the NVIDIA Container Toolkit and start with
--gpus=all. With an old host driver Ollama silently falls back to CPU.
If VRAM is tight, lower num_ctx or pull a Q4_K_S quantization. Ollama’s OLLAMA_GPU_OVERHEAD can reserve VRAM for your desktop, as this GPU guide explains. For the full Ubuntu walkthrough, including security, read our guide to running a local LLM on Ubuntu.
Putting the GPU to work with AILinux
A GPU on its own only answers prompts. AILinux is an Ubuntu-based distribution with an AI system agent for coding, DevOps and system administration, with model routing across local and external providers. That lets inference run on your local models while the operating system, files and execution stay on your machine. The agent works on Linux through MCP tools with configurable permissions and approval controls, instead of living in a browser chat. You can download AILinux 26.05, or see the full product line, including the ai-coder and the TriForce MCP server.

For background on what a Linux system with an AI layer looks like day to day, read Linux AI: what it means and how to run it locally.
FAQ
What GPU should I buy for local AI?
For most developers, a 24 GB card is the target: a used RTX 3090 for value, or a 4090 or 5090 if the budget allows. It runs 30B to 35B models at Q4. If you only need 7B to 8B models, a 12 GB card such as the RTX 3060 is enough.
How much VRAM do I need for a local LLM?
At Q4_K_M, roughly 8 GB for a 7B model, 11 to 13 GB for 13B to 14B, about 24 GB for 30B to 35B and about 48 GB for 70B at 8K context. Longer context adds more, so leave headroom.
Can I run local AI without a GPU?
Yes, but CPU inference is 10x to 100x slower than on a GPU, so it only suits small models and light use.
Does a second GPU make a model faster?
No. A second card adds memory, so larger models fit, but llama.cpp’s default layer split runs the cards one after another for each token, so speed doesn’t double.
Sources
- A Guide to Local AI (Stanford)
- Tech Primer: What hardware do you need to run a local LLM?
- How Much VRAM to Run an LLM (7B to 70B)
- VRAM requirements for local LLMs by model size and quant
- What LLM fits my GPU? 178-model VRAM index
- How Much VRAM Do You Need for a Local LLM? Measured
- Best AI Rig for Local LLMs 2026
- RTX 4090 vs RTX 5090 for Local LLM Inference
- Budget AI Server Build
- 27.4 Hardware, Dive into Deep Learning
- Ollama in Docker with GPU
- Ollama GPU Setup: CUDA, ROCm, Metal, and Troubleshooting
- How to Run LLMs Locally on Linux with Ollama
- Running Local LLMs on Linux
- Ollama GPU Setup: Run Local LLMs on an NVIDIA RTX Card
- Ollama GPU Acceleration



