Free tools / LLM memory calculator / Llama 3.1 8B
Llama 3.1 8B VRAM and RAM requirements
Llama 3.1 8B needs about 6.4 GB of VRAM in Q4_K_M, the quantization Ollama downloads by default, at a 4K context, and about 23 GB at its full 128K context. The weights take about 4.9 GB and the rest is the context cache plus about 1 GB for the GPU runtime. On a CPU server without a GPU it needs about 6.9 GB of RAM at 4K.
Llama 3.1 8B is Meta's 8B instruct model and a common default for local chat and agents.
Llama 3.1 8B memory by quantization and context
Memory Llama 3.1 8B needs for each quantization at 4K, 32K, 128K tokens of context. VRAM total adds about 1 GB for the GPU runtime, RAM total about 1.5 GB for the system and Ollama on a CPU server.
| Quantization | Context | Weights | KV cache | VRAM total | RAM total (CPU) |
|---|---|---|---|---|---|
| Q4_K_M | 4K | 4.9 GB | 0.5 GB | 6.4 GB | 6.9 GB |
| 32K | 4.9 GB | 4.3 GB | 10 GB | 11 GB | |
| 128K | 4.9 GB | 17 GB | 23 GB | 24 GB | |
| Q5_K_M | 4K | 5.7 GB | 0.5 GB | 7.2 GB | 7.7 GB |
| 32K | 5.7 GB | 4.3 GB | 11 GB | 12 GB | |
| 128K | 5.7 GB | 17 GB | 24 GB | 24 GB | |
| Q6_K | 4K | 6.6 GB | 0.5 GB | 8.1 GB | 8.6 GB |
| 32K | 6.6 GB | 4.3 GB | 12 GB | 12 GB | |
| 128K | 6.6 GB | 17 GB | 25 GB | 25 GB | |
| Q8_0 | 4K | 8.5 GB | 0.5 GB | 10 GB | 11 GB |
| 32K | 8.5 GB | 4.3 GB | 14 GB | 14 GB | |
| 128K | 8.5 GB | 17 GB | 27 GB | 27 GB | |
| FP16 | 4K | 16 GB | 0.5 GB | 18 GB | 18 GB |
| 32K | 16 GB | 4.3 GB | 21 GB | 22 GB | |
| 128K | 16 GB | 17 GB | 34 GB | 35 GB |
Weights are the parameter count times the bits per weight of each quantization, the KV cache comes from the layer and attention head counts in the model config at FP16, as Ollama stores it by default. The sizes match Ollama downloads within a few percent.
GPUs that fit Llama 3.1 8B
In Q4_K_M at 4K, the cheapest GPU server that holds Llama 3.1 8B is the A16 (16 GB) at about $0.658 an hour, generating about 35 tokens per second. A 24 GB card such as the L4 or A10 holds it in Q4_K_M even at the full 128K context. Unquantized FP16 needs about 18 GB, which starts at the RTX 4000 Ada (20 GB).
| Llama 3.1 8B setup | VRAM needed | Cheapest GPU servers that fit |
|---|---|---|
| Q4_K_M at 4K | 6.4 GB |
|
| Q4_K_M at 128K | 23 GB |
|
| Q8_0 at 4K | 10 GB |
|
| FP16 at 4K | 18 GB |
|
Prices are for the cheapest city of each card, billed by the hour. Speed is generation with Ollama, estimated from memory bandwidth and our runs on the LLM speed benchmark. All cards are on the GPU servers page.
Running Llama 3.1 8B on a CPU server
Yes, a CPU-only server with 8 GB of RAM holds Llama 3.1 8B in Q4_K_M at 4K, since it needs about 6.9 GB. On 2 dedicated vCPU expect about 4 tokens per second, slower than reading speed, fine for short answers and batch jobs. On 4 shared vCPU it makes about 3.5 tokens per second. At the full 128K context the RAM need grows to about 24 GB.
| CPU server | RAM | Tokens/s in Q4_K_M | Price |
|---|---|---|---|
| 4 shared vCPUHetzner | 8 GB | about 3.5 | $18/mo$0.025/hr |
| 2 dedicated vCPUOVHcloud | 16 GB | about 4 | $83/mo$0.114/hr |
Llama 3.1 8B in Ollama
ollama run llama3.1:8b downloads the Q4_K_M build. Every quantization in the table has its own tag, listed next to its row.
- Q4_K_M
ollama run llama3.1:8b - Q5_K_M
ollama run llama3.1:8b-instruct-q5_K_M - Q6_K
ollama run llama3.1:8b-instruct-q6_K - Q8_0
ollama run llama3.1:8b-instruct-q8_0 - FP16
ollama run llama3.1:8b-instruct-fp16
What to know about Llama 3.1 8B
- At 128K the context cache (about 17 GB) outgrows the Q4_K_M weights (about 4.9 GB). Raise num_ctx only as far as your prompts need.
Frequently asked questions
How much VRAM does Llama 3.1 8B need?
About 6.4 GB in Q4_K_M at a 4K context, about 10 GB in Q8_0 and about 18 GB in FP16. The cheapest GPU that holds it in Q4_K_M is the A16 (16 GB). A longer context adds more: about 23 GB in Q4_K_M at 128K.
Can Llama 3.1 8B run on a CPU without a GPU?
Yes, a CPU-only server with 8 GB of RAM holds Llama 3.1 8B in Q4_K_M at 4K, since it needs about 6.9 GB. On 2 dedicated vCPU expect about 4 tokens per second, slower than reading speed, fine for short answers and batch jobs. On 4 shared vCPU it makes about 3.5 tokens per second. At the full 128K context the RAM need grows to about 24 GB.
How much memory does Llama 3.1 8B need for a 128K context?
About 23 GB of VRAM or 24 GB of RAM in Q4_K_M. The context cache alone takes about 17 GB at 128K tokens, next to about 4.9 GB of weights. Ollama uses a 4K context unless you raise num_ctx, so the cache stays small by default.
Similar models
Further reading
VRAM and RAM for other models
- Llama 3.2 3B
- Qwen 2.5 7B
- DeepSeek R1 7B
- Qwen3 8B
- Qwen 2.5 14B
- DeepSeek R1 14B
- Phi-4 14B
- Qwen3 14B
- Mistral Small 3 24B
- Qwen 2.5 32B
- DeepSeek R1 32B
- Qwen3 32B
- Llama 3.3 70B
- DeepSeek R1 70B
Another model, quantization or context? Use the LLM VRAM and RAM calculator