llmrun
MetaCode LlamaLlamaForCausalLM

CodeLlama 7B Instruct HF — Hardware Requirements & GPU Compatibility

ChatCode

CodeLlama 7B Instruct HF is a 6.7B-parameter open language model from Meta in the Code Llama family. It supports a context window of up to 16,384 tokens. At Q4_K_M it needs about 5.42 GB of VRAM — see which GPUs and Macs can run it below.

6.7B params · dense16K contextLlama 2 Community41.0K downloads258 likes4.1K quant downloads
S

Runs great on a 24 GB GPU

Runs from8 GB Q4_K_M · 4KBest on24 GB Q4_K_M · ~149 tok/s · 16KMacs from16 GB Q4_K_M · ~31 tok/s

Llama 2 Community

Reference GPU · RTX 4090 24 GB

Estimates, ±20% · how we estimate

Run CodeLlama 7B Instruct HF

One recommended way. Every other method, OS and quant is in the step-by-step guide.Each way opens a step-by-step guide for your OS and quant.

Recommended

Ollama
one command · needs Ollama installed
$ollama run codellama:7b-instruct-q4_K_M

Q4_K_M fits fully on the RTX 4090 · 11.1 GB free · 16K context

Download: CodeLlama-7b-Instruct-hf.Q4_K_M.gguf4.08 GBmradermacher

install, OS, other quants

Ways to runOther ways

each opens step-by-step

Run in cloud

Runs on RTX 5070 Ti (16 GB) (3 GB headroom) · Q4_K_M

Generation speed
~132 tok/s
generation speed
Cost per 1M output tokens
$0.34
per 1M output tokens

How Much VRAM Does CodeLlama 7B Instruct HF Need?

Select a quantization level; the listed hardware adheres to it.

QuantizationVRAM+32KOn RTX 4090 (reference)
4.2 GB—2-bit · K-quant — 2-bit quantization with K-quant improvementsFits: 16K context · ~190 tok/s
4.3 GB—3-bit small — 3-bit small quantizationFits: 16K context · ~187 tok/s
4.7 GB—3-bit medium — 3-bit medium quantizationFits: 16K context · ~173 tok/s
4.7 GB—4-bit · legacy — 4-bit legacy quantizationFits: 16K context · ~170 tok/s
5.4 GB—4-bit medium — 4-bit medium quantization — most popular sweet spotFits: 16K context · ~149 tok/s
6.2 GB—5-bit medium — 5-bit medium quantization — good quality/size tradeoffFits: 16K context · ~131 tok/s
6.9 GB—6-bit, very good — 6-bit quantization, very good qualityFits: 16K context · ~116 tok/s
8.1 GB—8-bit, near-lossless — 8-bit quantization, near-losslessFits: 16K context · ~99 tok/s
est.calculated, no published file yet

Selected Q4_K_M

4-bit medium quantization

12.9GBat 16K context

Weights
4.1 GB
KV cache
8.6 GB
Overhead
0.3 GB

Fits RTX 4090 (reference) · 11.1 GB free · ~149 tok/s

≥50 tok/s needs ≥338 GB/s · RTX 5090 ~265, RTX 3090 Ti ~149

Which Hardware Can Run CodeLlama 7B Instruct HF?

Q4_K_M · 5.4 GB

CodeLlama 7B Instruct HF (Q4_K_M) requires 5.4 GB of VRAM to load the model weights. For comfortable inference with headroom for KV cache and system overhead, 8+ GB is recommended. Using the full 16K context window can add up to 7.5 GB, bringing total usage to 12.9 GB. 107 GPUs can run it, including NVIDIA GeForce RTX 5090, NVIDIA GeForce RTX 3090 Ti, NVIDIA GeForce RTX 3070 Ti. 172 devices with unified memory can run CodeLlama 7B Instruct HF, including Mac Studio M5 Ultra (256 GB), Mac Studio M5 Ultra (512 GB), NVIDIA Jetson Orin Nano 8GB (Super).

By VRAM tier · typical GPUs and Macs at Q4_K_M
8 GB · RTX 4060Q4_K_M · 12.9 GB · ~40 tok/s · 4Ktight8 GB tier →
12 GB · RTX 3060 12GBQ4_K_M · 12.9 GB · ~53 tok/s · 8Ktight12 GB tier →
16 GB · RTX 5060 Ti 16GBQ4_K_M · 12.9 GB · ~66 tok/s · 16K16 GB tier →
24 GB · RTX 4090referenceQ4_K_M · 12.9 GB · ~149 tok/s · 16K24 GB tier →
Mac 32 GB · Mac Mini M4Q4_K_M · 12.9 GB · ~20 tok/s · 16KMacs →
Mac 64 GB · Mac Studio M4 MaxQ4_K_M · 12.9 GB · ~72 tok/s · 16KMacs →

Alternatives to CodeLlama 7B Instruct HF

Code Llama family · 4 models →

Similar models

6
ModelScoreVRAMtok/sWhy it is similar
Mathstral 7B v0.1Mistral AI—6.8 GB~164same size
Mistral 7B Instruct v0.3Mistral AI—6.8 GB~164same size
CodeQwen1.5 7BAlibaba—5.7 GB~169same size
Starling LM 7B BetaNexusflow—5.7 GB~164same size
Llava 1.5 7B HFllava-hf—5 GB~173same size
Chatglm3 6BZ.ai—5.2 GB~196same size

Specifications

Publisher
Meta
Parameters
6.7B
Architecture
LlamaForCausalLM
Context Length
16,384 tokens
Vocabulary Size
32,016
Release Date
2023-08-24
License
Llama 2 Community

Frequently Asked Questions

How much VRAM does CodeLlama 7B Instruct HF need?

CodeLlama 7B Instruct HF requires 5.4 GB of VRAM at Q4_K_M, or 14.8 GB at BF16. Full 16K context adds up to 7.5 GB (12.9 GB total).

VRAM = Weights + KV Cache + Overhead

Weights = 6.7B × 4.8 bits ÷ 8 = 4 GB

KV Cache + Overhead ≈ 1.4 GB (at 2K context + ~0.3 GB framework)

Fit ratings and hardware model lists check this model with room for a 16K-token context, which needs a little more memory.

KV Cache + Overhead ≈ 8.9 GB (at full 16K context)

VRAM usage by quantization

5.4 GB
12.9 GB

Learn more about VRAM estimation →

What's the best quantization for CodeLlama 7B Instruct HF?

For CodeLlama 7B Instruct HF, Q4_K_M (5.4 GB) offers the best balance of quality and VRAM usage. Q5_0 (5.6 GB) provides better quality if you have the VRAM. The smallest option is IQ3_XS at 4.2 GB.

VRAM requirement by quantization

IQ3_XS
4.2 GB
IQ3_M
4.4 GB
IQ4_XS
5.0 GB
Q4_K_M ★
5.4 GB
Q5_K_S
6.0 GB
BF16
14.8 GB

★ Recommended — best balance of quality and VRAM usage.

Learn more about quantization →

Can I run CodeLlama 7B Instruct HF on a Mac?

Yes — Mac Mini M2 Pro (16 GB) and 145 other Macs can run CodeLlama 7B Instruct HF. Apple Silicon uses unified memory, so the model shares RAM with the system. At Q4_K_M you need at least 5.4 GB of usable unified memory (RAM minus macOS overhead).

Can I run CodeLlama 7B Instruct HF locally?

Yes — CodeLlama 7B Instruct HF can run locally on consumer hardware. Popular tools include Ollama, LM Studio, and llama.cpp.

How fast is CodeLlama 7B Instruct HF?

At Q4_K_M, CodeLlama 7B Instruct HF can reach ~1181 tok/s on AMD Instinct MI350X. On NVIDIA GeForce RTX 4090: ~149 tok/s. Speed depends mainly on GPU memory bandwidth. Real-world results typically within ±20%.

tok/s = (bandwidth GB/s ÷ model GB) × efficiency

Example: AMD Instinct MI350X → 8000 ÷ 5.42 × 0.80 = ~1181 tok/s

Estimated speed at Q4_K_M (5.4 GB)

~1181 tok/s
~149 tok/s
~1181 tok/s
~1181 tok/s

Real-world results typically within ±20%. Speed depends on batch size, quantization kernel, and software stack.

Learn more about tok/s estimation →

What's the download size of CodeLlama 7B Instruct HF?

At Q4_K_M, the download is about 4.04 GB. The full-precision BF16 version is 13.48 GB. The smallest option (IQ3_XS) is 2.78 GB.

Which GPUs can run CodeLlama 7B Instruct HF?

107 consumer GPUs can run CodeLlama 7B Instruct HF at Q4_K_M. Top options include AMD Radeon RX 6700 XT, AMD Radeon RX 6700M, AMD Radeon RX 6750 XT, AMD Radeon RX 5600 XT. 51 GPUs have plenty of headroom for comfortable inference.

Which devices can run CodeLlama 7B Instruct HF?

172 devices with unified memory can run CodeLlama 7B Instruct HF at Q4_K_M (5.4 GB), including AMD Ryzen 7 8845HS (Hawk Point) Laptop, AMD Ryzen AI 7 350 (Krackan Point) Laptop, AMD Ryzen AI 9 HX 370 (Strix Point) Laptop, ASUS Ascent GX10. Apple Silicon Macs use unified memory shared between CPU and GPU, making them well-suited for local LLM inference.