selfhost.directory

The index of self-hostable projects — ranked, categorized and served with live updates.
Own your data and stop giving it to big tech.

meta-llama logo

Llama-3.1-8B-Instruct

meta-llama·Instruct·released 18 Jul 2024

Llama 3.1 Community License8B128K ctx ≈6.3 GBgated
Your GPU
ollama run llama3.1:8b
All 7 runners ↓

Llama-3.1-8B-Instruct is an 8B-parameter chat and text generation model from Meta's meta-llama organisation, part of the Llama 3.1 family. It takes text input and produces text output, with a context window of 131,072 tokens. It is released under the Llama 3.1 Community License, which limits commercial use, and the download is gated. Within the family, it is the 8B instruct variant, smaller than the 70B and 405B instruct models.

How much VRAM does Llama-3.1-8B-Instruct need?

At Q4_K_M Llama-3.1-8B-Instruct needs about 6.3 GB with an 8K context (6.3 GB at Q4, 17 GB at full precision). Pick your GPU to see what fits and how fast it runs.

--vram
any
--gpus
--quant

Needs: ≈6.3 GB · Q4_K_M · 8K context — Pick a GPU to check the fit.

Change quant, context or KV cache to compare
Advanced: context 8K · KV cache 16-bit
Context
KV cache

Smallest GPU for each quant and context (KV cache 16-bit)

Quantisation4K8K16K32K64K128K
Q3_K_M
Q4_K_M
Q5_K_M
Q6_K
Q8_0
FP16

≤16 GB card24–32 GB48–96 GBmore

QuantisationQualityWeightsKV cacheTotal
Q2_KHeavy lossSmallest, noticeably worse qualityHeavy loss3.0 GB file1.0 GB≈4.6 GB
Q3_K_MNoticeable lossSmall, some quality lossNoticeable loss3.7 GB file1.0 GB≈5.4 GB
Q4_K_MrecommendedSmall lossRecommended default for local useSmall loss4.6 GB file1.0 GB≈6.3 GB
Q5_K_MNear-losslessNear-lossless for most tasksNear-lossless5.3 GB file1.0 GB≈7.1 GB
Q6_KNear-losslessPractically losslessNear-lossless6.1 GB file1.0 GB≈8.0 GB
Q8_0LosslessLossless in practice, twice the size of Q4Lossless8.0 GB est.1.0 GB≈9.8 GB
FP16 / BF16LosslessFull precision, as releasedLossless15 GB file1.0 GB≈17 GB

Estimates for 8K tokens of context: weights + KV cache + runtime overhead. Speed assumes memory-bound decoding at your GPU’s bandwidth. Pick a GPU above and the fit column checks every row against it. Weights marked “file” use the real GGUF download size; “est.” rows are computed from the parameter count.

How to pick a quant

Take the biggest quant that fits with room left for context. Q4_K_M is the usual sweet spot. Below Q4 quality drops fast, above Q6 you mostly pay memory for nothing. Big models (70B+, large MoE) tolerate low quants better than small ones.

  • LosslessF16, Q8_0
  • Near-losslessQ6_K, Q5_K_M
  • Small lossQ5_K_S, Q4_K_M, IQ4_NL, IQ4_XS, Q4_K_S
  • Noticeable lossQ4_0, Q3_K_L, Q3_K_M, IQ3_M
  • Heavy lossIQ3_XXS, Q3_K_S, IQ2_M, Q2_K

Typical quality loss, not measured per model. Tiers come from KL divergence against FP16 on Llama 3 8B: llama.cpp perplexity README: LLaMA 3 8B scoreboard (KLD and ΔPPL vs FP16, Wikitext-2); llama.cpp quantize tool: ΔPPL per quant type @ Llama-3-8B

How much context fits?

Model quant
KV cache

At 8K context, Q4_K_M needs ≈6.3 GB(4.6 GB weights + 1.0 GB KV cache + 0.7 GB overhead). Pick a GPU above to see how much context fits.

05101520251K2K4K8K16K32K64K128KGB

Weights + overheadKV cache

Can the RTX 4060 run Llama-3.1-8B-Instruct? →

Speed vs quality per quant

Smaller quants run faster and fit in less memory, but lose quality.

Q2_KQ3_K_MQ4_K_MQ5_K_MQ6_KQ8_0F16

Fits in VRAMTight fitCPU offload✕ won't runQuality is typical KL divergence vs FP16, not measured for this model.

Real-world speed of Llama-3.1-8B-Instruct

Tokens per second measured by people running it at home. A GPU shows a median once 3 reports agree on the same setup. Reports far from our estimate wait for a review. Measure yours with llama-bench →

No medians yet. Be one of the first 3 to report a setup.

All reports

Run Llama-3.1-8B-Instruct locally

--quantQ4_K_Mdefault; pick your GPU to tailor itunsloth/Llama-3.1-8B-Instruct-GGUF

From the Ollama librarydocs
ollama run llama3.1:8b

The library build picks its own default quantisation.

Q4_K_M straight from Hugging Facedocs
ollama run hf.co/unsloth/Llama-3.1-8B-Instruct-GGUF:Q4_K_M

Install Ollama

OpenAI-compatible server with a web UIdocs
llama-server -hf unsloth/Llama-3.1-8B-Instruct-GGUF:Q4_K_M

Downloads the GGUF on first run. Installed through llama.app? The same flags work with `llama serve`.

Install llama.cpp

Download with the lms CLIdocs
lms get unsloth/Llama-3.1-8B-Instruct-GGUF@Q4_K_M

Then load it from the LM Studio app or with `lms load`.

Install LM Studio

Apple Silicon with mlx-lmdocs
bash
pip install mlx-lm
mlx_lm.generate --model mlx-community/Llama-3.1-8B-Instruct-4bit --prompt "Hello"

Use `mlx_lm.chat` with the same --model for an interactive chat.

OpenAI-compatible serverdocs
mlx_lm.server --model mlx-community/Llama-3.1-8B-Instruct-4bit --port 8080

API on http://localhost:8080/v1.

Install MLX

Serve an OpenAI-compatible APIdocs
vllm serve meta-llama/Llama-3.1-8B-Instruct

Gated on Hugging Face: accept the licence on the model page and export HF_TOKEN first.

Smaller FP8 builddocs
vllm serve RedHatAI/Meta-Llama-3.1-8B-Instruct-FP8
Docker Compose (NVIDIA)docs
yaml
services:
  vllm:
    image: vllm/vllm-openai:latest
    command: meta-llama/Llama-3.1-8B-Instruct
    ports:
      - "8000:8000"
    ipc: host
    volumes:
      - ~/.cache/huggingface:/root/.cache/huggingface
    environment:
      - HF_TOKEN=${HF_TOKEN}
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

API on port 8000.

Install vLLM

Serve an OpenAI-compatible APIdocs
sglang serve meta-llama/Llama-3.1-8B-Instruct --host 0.0.0.0 --port 30000

Gated on Hugging Face: accept the licence on the model page and export HF_TOKEN first.

Docker Compose (NVIDIA)docs
yaml
services:
  sglang:
    image: lmsysorg/sglang:latest
    command: sglang serve meta-llama/Llama-3.1-8B-Instruct --host 0.0.0.0 --port 30000
    ports:
      - "30000:30000"
    ipc: host
    volumes:
      - ~/.cache/huggingface:/root/.cache/huggingface
    environment:
      - HF_TOKEN=${HF_TOKEN}
    deploy:
      resources:
        reservations:
          devices:
            - driver: nvidia
              count: all
              capabilities: [gpu]

API on port 30000.

Install SGLang

Chat with the pipeline APIdocs
python
from transformers import pipeline

pipe = pipeline("text-generation", model="meta-llama/Llama-3.1-8B-Instruct", dtype="auto", device_map="auto")
messages = [{"role": "user", "content": "Explain self-hosting in one paragraph."}]
out = pipe(messages, max_new_tokens=512)
print(out[0]["generated_text"][-1]["content"])

Gated on Hugging Face: accept the licence on the model page and export HF_TOKEN first.

Install Transformers

Benchmarks

BenchmarkScoreRankSourceDate
MMLU-Pro38.0%#172 / 409 independentFeb 2025
GPQA Diamond30.4%#96 / 104 self-reportedJan 2026
GPQA31.5%#69 / 310 independentFeb 2025
IFEval49.2%#105 / 312 independentFeb 2025
BIG-Bench Hard50.9%#90 / 310 independentFeb 2025
MATH Level 515.6%#93 / 310 independentFeb 2025
MuSR39.7%#146 / 310 independentFeb 2025
Open LLM Leaderboard v2 average23.76#95 / 310 independentFeb 2025
GSM8K84.5%#16 / 38 self-reportedMar 2026
LMArena Text1187#89 / 127 independentOct 2026
BFCL v425.8%#24 / 36 independentOct 2026

Self-reported scores come from the model card and are not independently verified. Rank is among all models with a score on that benchmark.

Quantised versions and downloads

RepositoryFormatQuantSizeDownloads
unsloth/Meta-Llama-3.1-8B-Instruct-bnb-4bitSafetensorsBNB-4BIT—88.5K
unsloth/Meta-Llama-3.1-8B-Instruct-unsloth-bnb-4bitSafetensorsBNB-4BIT—25.7K
RedHatAI/Meta-Llama-3.1-8B-Instruct-FP8SafetensorsFP8—47K
unsloth/Llama-3.1-8B-Instruct-GGUFGGUFUD-IQ1_S2.2 GB17.8K
unsloth/Llama-3.1-8B-Instruct-GGUFGGUFUD-IQ1_M2.3 GB17.8K
unsloth/Llama-3.1-8B-Instruct-GGUFGGUFUD-IQ2_XXS2.5 GB17.8K
unsloth/Llama-3.1-8B-Instruct-GGUFGGUFUD-IQ2_M3.0 GB17.8K
unsloth/Llama-3.1-8B-Instruct-GGUFGGUFQ2_K3.2 GB17.8K
unsloth/Llama-3.1-8B-Instruct-GGUFGGUFQ2_K_L3.3 GB17.8K
unsloth/Llama-3.1-8B-Instruct-GGUFGGUFUD-IQ3_XXS3.3 GB17.8K

About Llama-3.1-8B-Instruct

The Meta Llama 3.1 collection of multilingual large language models (LLMs) is a collection of pretrained and instruction tuned generative models in 8B, 70B and 405B sizes (text in/text out). The Llama 3.1 instruction tuned text only models (8B, 70B, 405B) are optimized for multilingual dialogue use cases and outperform many of the available open source and closed chat models on common industry benchmarks. Model developer: Meta Model Architecture: Llama 3.1 is an auto-regressive language model that uses an optimized transformer architecture. The tuned versions use supervised fine-tuning (SFT) and reinforcement learning with human feedback (RLHF) to align with human preferences for helpfulness and safety. Training Data Params Input modalities Output modalities Context length GQA Token count Knowledge cutoff Llama 3.1 (text only) A new mix of publicly available online data. 8B Multilingual Text Multilingual Text and code 128k Yes 15T+ December 2023 70B Multilingual Text Multilingual Text and code 128k Yes 405B Multilingual Text Multilingual Text and code 128k Yes Supported languages: English, German, French, Italian, Portuguese, Hindi, Spanish, and Thai. Llama 3.1 family of models. Token counts refer to pretraining data only. All model versions use Grouped-Query Attention (GQA) for improved inference scalability. Model Release Date: July 23, 2024.

Full model card on Hugging Face →

Other Llama 3.1 models

Whole family →
meta-llama logo
Llama-3.1-8Bmeta-llama
8BConditions≈6.3 GB↓ 519.4K
meta-llama logo
Llama-3.1-70Bmeta-llama
70.6BConditions≈45 GB↓ 27.6K
meta-llama logo70.6BConditions≈45 GB↓ 91.6K
meta-llama logo
Llama-3.1-405Bmeta-llama
406BConditions≈248 GB↓ 45.2K
meta-llama logo406BConditions≈248 GB↓ 9.2K

Alternatives to Llama-3.1-8B-Instruct

All alternatives →
ornith-ai logo

Ornith-1.0-9B

ornith-ai·Chat

≈6.8 GB

Aloha! 🌺 Today, we are releasing Ornith-1.0, a self-improving family of open-source models for agentic coding.

9B256K ctx MIT
804.7KJun 2026gguf
Qwen logo

Qwen3-8B

Qwen·Chat

≈6.5 GB

Qwen3 is the latest generation of large language models in Qwen series, offering a comprehensive suite of dense and mixture-of-experts (MoE) models.

8.2B40K ctx Apache 2.0
7MApr 2025ollama
ornith-ai logo

Ornith-1.5-9B

ornith-ai·Chat

≈7.2 GB

Chirp Chirp! 🐦 We are introducing Ornith-1.5, a major step toward building foundation models through end-to-end self-improvement.

9.7B256K ctx MIT
494.1KAug 2026ollama
IFM logo

K2-Horizon-7B

IFM·Chat

≈7.0 GB

K2-Horizon-7B is the medium dense member of the K2-Horizon family: a 7B-core decoder-only model with a 512K context window.

9B512K ctx Apache 2.0
84.5KSept 2026gguf

NVIDIA-Nemotron-3.5-Bolt-E4B-BF16 is a small language model (SLM) further post-trained from Gemma-4-E4B-it by NVIDIA. This is the full-precision (BF16) release.

8B64K ctx openmdw-1.1
22.8KOct 2026gguf
ibm-granite logo

granite-4.2-8b

ibm-granite·Chat

≈7.0 GB

Granite is a family of open-source large language models developed by IBM, designed for enterprise and research use. Granite models are built to be versatile, safe, and efficient — covering a range of sizes and capabilities from compact edge-deployable models to large-scale reasoning systems.

8.8B128K ctx Apache 2.0
68.3KAug 2026ollama

Llama-3.1-8B-Instruct FAQ

How much VRAM does Llama-3.1-8B-Instruct need?
About 6.3 GB at Q4_K_M with an 8K context. Q8_0 needs about 9.8 GB and full precision about 17 GB. Longer contexts need more memory for the KV cache.
Can Llama-3.1-8B-Instruct run on the RTX 4060?
Yes. It fits at Q5_K_M (about 7.1 GB), at an estimated 26 tokens/s. It fits comfortably on the Apple M4 (16 GB), Radeon RX 6700 XT, RTX 3060 12GB.
Can I use Llama-3.1-8B-Instruct commercially?
Yes, with conditions. It is released under Llama 3.1 Community License. Free for commercial use unless you have over 700M monthly active users; requires "Built with Llama" attribution and follows the acceptable use policy.
What is the context length of Llama-3.1-8B-Instruct?
131,072 tokens (128K). The full window needs far more memory than an 8K context.
How do I run Llama-3.1-8B-Instruct with Ollama or llama.cpp?
With Ollama: ollama run llama3.1:8b. With llama.cpp: llama-server -hf unsloth/Llama-3.1-8B-Instruct-GGUF:Q4_K_M, which starts an OpenAI-compatible server.

Data from Hugging Face, the model card and public leaderboards. Memory and speed figures are estimates; real numbers depend on the runtime, context length and drivers. Always check the licence yourself before commercial use.