Code Llama 7B Instruct

Llama 2 7B fine-tuned for code generation and infilling with a 16K context window.

Meta·6.74B params·32 layers / 32 KV heads·Max 16K ctx·Llama 2 Community
Local Run Command
Q4_K_M minimum memory: 12.7 GB at 16K context.
Artificial Analysis Benchmarkartificialanalysis.ai ↗
Intelligence Index
—

Independent benchmark scores sourced from Artificial Analysis.

OpenRouter API & Cloud GPU
No live OpenRouter route synced.

VRAM by Quantization (16K context)

Q4_K_M (4-bit)3.8 GB
real file size
8.0 GB12.7 GB8.7 GBBest speed-to-quality balance for local inference (~98% quality)
ollama run codellama:7b-code-q4_K_M
Q6_K (6-bit)5.2 GB
real file size
8.0 GB14.1 GB10.1 GBNear-lossless quality with ~35% larger footprint than Q4
ollama run codellama:7b-code-q6_K
Q8_0 (8-bit)6.7 GB
real file size
8.0 GB15.7 GB11.7 GBVirtually indistinguishable from FP16 for coding & reasoning
ollama run codellama:7b-code-q8_0
FP16 / BF16 (16-bit)12.6 GB
real file size
8.0 GB21.9 GB17.9 GBFull native precision; standard for production GPU serving
ollama run codellama:7b-code-fp16

Layer and head counts are read from the published config.json. KV cache is exact for this architecture.

Run Code Llama 7B Instruct with Ollama, LM Studio, llama.cpp, MLX or vLLM

Command
Ollama
Q4_K_M
codellama:7b-code-q4_K_M
3.8 GB
real file size
LM Studio
Q4_K_M
3.8 GB
estimate
Not in LM Studio's catalog.
llama.cpp
Q4_K_M
3.8 GB
estimate
No Q4_K_M GGUF of this model found on Hugging Face.
MLX
4-bit
3.6 GB
estimate
No 4-bit MLX build of this model on mlx-community. Convert one with mlx_lm.convert.
vLLM
INT4
4.1 GB
estimate
No INT4 build of this model found for vLLM.

Each runtime loads its own build of the model, so download sizes differ. Sizes marked as real are file sizes read from the Ollama registry or Hugging Face.

Hardware Compatibility Matrix (Q4_K_M · 16K context)

Details
11.5 GBPartial offload4.2–9.8 tok/s—Code Llama 7B Instruct on M1 16GB →
48.0 GBFits comfortably44–60 tok/s—Code Llama 7B Instruct on M1 Max 64GB →
98.0 GBFits comfortably67–91 tok/s—Code Llama 7B Instruct on M1 Ultra 128GB →
18.0 GBFits comfortably17.5–24 tok/s—Code Llama 7B Instruct on M2 24GB →
48.0 GBFits comfortably53–72 tok/s—Code Llama 7B Instruct on M2 Max 64GB →
152 GBFits comfortably75–101 tok/s—Code Llama 7B Instruct on M2 Ultra 192GB →
27.0 GBFits comfortably25–33 tok/s—Code Llama 7B Instruct on M3 Pro 36GB →
48.0 GBFits comfortably54–72 tok/s—Code Llama 7B Instruct on M3 Max 64GB →
98.0 GBFits comfortably54–72 tok/s—Code Llama 7B Instruct on M3 Max 128GB →
11.5 GBPartial offload7.1–16.5 tok/s—Code Llama 7B Instruct on M4 16GB →
24.0 GBFits comfortably19.3–26 tok/s—Code Llama 7B Instruct on M4 32GB →
36.0 GBFits comfortably41–55 tok/s—Code Llama 7B Instruct on M4 Pro 48GB →
48.0 GBFits comfortably41–55 tok/s—Code Llama 7B Instruct on M4 Pro 64GB →
48.0 GBFits comfortably67–91 tok/s—Code Llama 7B Instruct on M4 Max 64GB →
98.0 GBFits comfortably67–91 tok/s—Code Llama 7B Instruct on M4 Max 128GB →
98.0 GBFits comfortably67–91 tok/s—Code Llama 7B Instruct on Studio M4 Max 128GB →
204 GBFits comfortably76–103 tok/s—Code Llama 7B Instruct on M3 Ultra 256GB →
430 GBFits comfortably76–103 tok/s—Code Llama 7B Instruct on M3 Ultra 512GB →
24.0 GBFits comfortably30–41 tok/s—Code Llama 7B Instruct on M1 Pro 32GB →
24.0 GBFits comfortably31–42 tok/s—Code Llama 7B Instruct on M2 Pro 32GB →
27.0 GBFits comfortably46–62 tok/s—Code Llama 7B Instruct on M3 Max 36GB →
11.5 GBPartial offload7.1–16.5 tok/s—Code Llama 7B Instruct on Air M4 16GB →
24.0 GBFits comfortably19.3–26 tok/s—Code Llama 7B Instruct on Air M4 32GB →
18.0 GBFits comfortably41–55 tok/s—Code Llama 7B Instruct on M4 Pro 24GB →
11.5 GBPartial offload8.7–20 tok/s—Code Llama 7B Instruct on Air M5 16GB →
24.0 GBFits comfortably26–35 tok/s—Code Llama 7B Instruct on Air M5 32GB →
48.0 GBFits comfortably52–70 tok/s—Code Llama 7B Instruct on M5 Pro 64GB →
98.0 GBFits comfortably87–118 tok/s—Code Llama 7B Instruct on M5 Max 128GB →
24.0 GBFits comfortably29–39 tok/s—Code Llama 7B Instruct on mini M6 32GB →
48.0 GBFits comfortably52–70 tok/s—Code Llama 7B Instruct on mini M5 Pro 64GB →
98.0 GBFits comfortably87–118 tok/s—Code Llama 7B Instruct on Studio M5 Max 128GB →
430 GBFits comfortably136–183 tok/s—Code Llama 7B Instruct on Studio M5 Ultra 512GB →
11.2 GBPartial offload11.4–12.0 tok/s2×Code Llama 7B Instruct on RTX 3060 12GB →
9.2 GBToo large—2×Code Llama 7B Instruct on RTX 3080 10GB →
22.8 GBFits comfortably122–166 tok/s1×Code Llama 7B Instruct on RTX 3090 24GB →
15.0 GBFits comfortably51–69 tok/s1×Code Llama 7B Instruct on RTX 4060 Ti 16GB →
15.0 GBFits comfortably107–144 tok/s1×Code Llama 7B Instruct on RTX 4070 Ti S 16GB →
15.0 GBFits comfortably120–162 tok/s1×Code Llama 7B Instruct on RTX 4080 S 16GB →
22.8 GBFits comfortably140–189 tok/s1×Code Llama 7B Instruct on RTX 4090 24GB →
15.0 GBFits comfortably143–193 tok/s1×Code Llama 7B Instruct on RTX 5070 Ti 16GB →
15.0 GBFits comfortably147–199 tok/s1×Code Llama 7B Instruct on RTX 5080 16GB →
30.5 GBFits comfortably229–310 tok/s1×Code Llama 7B Instruct on RTX 5090 32GB →
22.8 GBFits comfortably142–192 tok/s1×Code Llama 7B Instruct on RX 7900 XTX 24GB →
15.0 GBFits comfortably95–129 tok/s1×Code Llama 7B Instruct on RX 9070 XT 16GB →
10.2 GBPartial offload12.0 tok/s2×Code Llama 7B Instruct on RTX 2080 Ti 11GB →
7.3 GBToo large—2×Code Llama 7B Instruct on RTX 3060 Ti 8GB →
7.3 GBToo large—2×Code Llama 7B Instruct on RTX 3070 8GB →
11.2 GBPartial offload12.0 tok/s2×Code Llama 7B Instruct on RTX 3080 Ti 12GB →
22.8 GBFits comfortably138–187 tok/s1×Code Llama 7B Instruct on RTX 3090 Ti 24GB →
7.3 GBToo large—2×Code Llama 7B Instruct on RTX 4060 8GB →
7.3 GBToo large—2×Code Llama 7B Instruct on RTX 4060 Ti 8GB →
11.2 GBPartial offload12.0 tok/s2×Code Llama 7B Instruct on RTX 4070 12GB →
11.2 GBPartial offload12.0 tok/s2×Code Llama 7B Instruct on RTX 4070 S 12GB →
11.2 GBPartial offload12.0 tok/s2×Code Llama 7B Instruct on RTX 4070 Ti 12GB →
15.0 GBFits comfortably113–152 tok/s1×Code Llama 7B Instruct on RTX 4080 16GB →
15.0 GBFits comfortably73–99 tok/s1×Code Llama 7B Instruct on RTX 5060 Ti 16GB →
11.2 GBPartial offload12.0 tok/s2×Code Llama 7B Instruct on RTX 5070 12GB →
15.0 GBFits comfortably88–120 tok/s1×Code Llama 7B Instruct on RX 7800 XT 16GB →
18.9 GBFits comfortably97–131 tok/s1×Code Llama 7B Instruct on RX 7900 XT 20GB →
15.0 GBFits comfortably95–128 tok/s1×Code Llama 7B Instruct on RX 9070 16GB →
15.0 GBFits comfortably56–75 tok/s1×Code Llama 7B Instruct on RX 9060 XT 16GB →
46.2 GBFits comfortably110–148 tok/s1×Code Llama 7B Instruct on RTX A6000 48GB →
46.2 GBFits comfortably138–187 tok/s1×Code Llama 7B Instruct on RTX 6000 Ada 48GB →
93.0 GBFits comfortably223–301 tok/s1×Code Llama 7B Instruct on PRO 6000 96GB →
15.0 GBFits comfortably67–91 tok/s1×Code Llama 7B Instruct on RTX A4000 16GB →
22.8 GBFits comfortably105–142 tok/s1×Code Llama 7B Instruct on RTX A5000 24GB →
18.9 GBFits comfortably62–83 tok/s1×Code Llama 7B Instruct on RTX 4000 Ada 20GB →
30.5 GBFits comfortably93–126 tok/s1×Code Llama 7B Instruct on RTX 5000 Ada 32GB →
46.2 GBFits comfortably128–213 tok/s1×Code Llama 7B Instruct on PRO 5000 48GB →
46.2 GBFits comfortably98–133 tok/s1×Code Llama 7B Instruct on PRO W7900 48GB →
30.5 GBFits comfortably95–128 tok/s1×Code Llama 7B Instruct on AI PRO R9700 32GB →
22.8 GBFits comfortably50–83 tok/s1×Code Llama 7B Instruct on L4 24GB →
46.2 GBFits comfortably116–157 tok/s1×Code Llama 7B Instruct on L40S 48GB →
38.5 GBFits comfortably136–227 tok/s1×Code Llama 7B Instruct on A100 40GB →
77.5 GBFits comfortably148–200 tok/s1×Code Llama 7B Instruct on A100 80GB →
77.5 GBFits comfortably175–237 tok/s1×Code Llama 7B Instruct on H100 80GB →
137 GBFits comfortably190–317 tok/s1×Code Llama 7B Instruct on H200 141GB →
175 GBFits comfortably206–343 tok/s1×Code Llama 7B Instruct on B200 180GB →
15.0 GBFits comfortably41–56 tok/s1×Code Llama 7B Instruct on T4 16GB →
46.2 GBFits comfortably95–128 tok/s1×Code Llama 7B Instruct on A40 48GB →
46.2 GBFits comfortably123–166 tok/s1×Code Llama 7B Instruct on L40 48GB →
115 GBFits comfortably46–63 tok/s—Code Llama 7B Instruct on DGX Spark 128GB →
96.0 GBFits comfortably41–55 tok/s—Code Llama 7B Instruct on Ryzen AI Max+ 395 128GB →
48.0 GBFits comfortably41–55 tok/s—Code Llama 7B Instruct on Ryzen AI Max+ 395 64GB →

Frequently asked questions

How much VRAM does Code Llama 7B Instruct require?

At Q4_K_M quantization with a 16K context window, Code Llama 7B Instruct needs 12.7 GB total VRAM (3.8 GB weights + 8.0 GB KV cache + runtime overhead). In full FP16 precision, it requires 21.9 GB.

Can an RTX 4090 (24 GB) run Code Llama 7B Instruct?

Yes. At Q4_K_M with 16K context Code Llama 7B Instruct needs 12.7 GB, which fits a single 24 GB RTX 4090 at an estimated 140–189 tok/s.

How do I run Code Llama 7B Instruct locally with Ollama?

Install Ollama and run `ollama run codellama:7b` in your terminal. Make sure your GPU or Apple Silicon unified memory meets the 12.7 GB Q4_K_M requirement.