GPU sizing determines the Video RAM (VRAM) and compute power needed for an AI model. This depends on parameter count, weight precision, and the number of concurrent users. VRAM is the main bottleneck for large language models [1]. Correct sizing prevents crashes and slow speeds.

To help you plan your infrastructure, we provide a free KV Cache and GPU VRAM Calculator for LLM Agents that handles the memory allocation math.

Understanding the VRAM bottleneck

GPU memory splits into two categories: model weights and the KV cache.

Model weights are static. For inference using fp16 precision, you need about 2 GB of VRAM per billion parameters [2]. Many users use quantization to lower this requirement. 4-bit or 8-bit quantization lets larger models fit on smaller cards by reducing bits per weight.

The KV cache is dynamic. It stores conversation context so the model does not re-process every previous token for every new word. In the formula below, the cache grows with the context length and with each agent you run at the same time. Underestimating the KV cache leads to out of memory (OOM) errors when conversations grow long or more users join.

Detailed image of illuminated server racks showcasing modern technology infrastructure. Photo by panumas nikhomkhai on Pexels
Detailed image of illuminated server racks showcasing modern technology infrastructure. Photo by panumas nikhomkhai on Pexels

How to calculate KV cache size

Manual KV cache calculation is hard because it depends on model architecture. The formula per agent is:

2 x layers x KV heads x head dim x bytes per value x context tokens.

The "2" covers both keys and values. Layers, heads, and dimensions are found in the config.json file on Hugging Face. Our calculator's worked example uses Qwen3-8B, and it reads these values from that model's configuration file: 36 layers, 8 KV heads and a head dimension of 128. An 8-bit cache for this model uses 73,728 bytes per token. One agent with a 32,768-token context window needs 2.25 GiB of VRAM for its cache.

Architectures vary. Sliding-window layers stop growing at their limit. Linear-attention layers use a small fixed state. Some models use compressed vectors to lower memory use per layer.

Worked example: sizing for qwen3-8b

Here is a scenario using our KV Cache and GPU VRAM Calculator for LLM Agents.

Assume you deploy Qwen/Qwen3-8B on one GPU with 24 GB of VRAM. Each agent needs a context window of 32,768 tokens.

  1. Load the Model: Pick Qwen3-8B from the list or paste the Hugging Face ID "Qwen/Qwen3-8B" and press Load.
  2. Set Hardware: Select 24 GB VRAM per card and set the card count to 1.
  3. Choose Quantization: Select a weight quantization like Q4_K_M. The tool uses GGUF file sizes or average bits per weight to find the VRAM cost.
  4. Configure Cache: Set the context to 32,768 tokens and choose the KV cache precision (e.g., 8-bit).

The tool subtracts model weights and a 2 GiB buffer from total VRAM. It uses 96% of VRAM for realistic planning. It divides the remaining memory by the 2.25 GiB required for one Qwen3-8B agent. The result shows how many agents the 24 GB card can serve.

Detailed view of RAM sticks and microprocessors on a motherboard. Photo by Sergei Starostin on Pexels
Detailed view of RAM sticks and microprocessors on a motherboard. Photo by Sergei Starostin on Pexels

Planning for total cost of ownership

Sizing balances performance and cost. Over-provisioning wastes money on idle VRAM. Under-provisioning causes high latency or failures [3].

Consider these factors when planning:

  • Concurrency: How many agents hit the GPU at the same millisecond?
  • Input/Output Length: Long prompts and responses need more KV cache space.
  • Precision: Moving from 16-bit to 8-bit or 4-bit quantization increases the number of agents per card.

Mapping workloads to categories like AI agents or chatbots helps predict token patterns and memory needs [3].

For a precise estimate of your hardware needs, use our KV Cache and GPU VRAM Calculator for LLM Agents to avoid the guesswork of manual VRAM planning.