# LLaMA 7B GPU Memory Requirement

> Source: <https://discuss.huggingface.co/t/llama-7b-gpu-memory-requirement/34323?page=2#post_22>
> Published: 2026-12-03 04:33:19+00:00

**Recommendation:** Load LLaMA 7B in FP16 and drop to bitsandbytes 4-bit when a T4 still runs out of memory; keep max_new_tokens and batch size low because the KV cache grows during generation.
More in the playbook "Inference and self-hosting": <https://wpnews.pro/playbooks/inference-serving>

The accepted answer gets the model loaded in FP16. One detail worth adding for anyone trying this on a T4: **when the OOM happens tells you what to change.**

`dtype=torch.float16` in current Transformers versions (`torch_dtype=torch.float16` in older versions). If FP16 still leaves too little room on the T4, 4-bit loading with bitsandbytes gives you more headroom. `LlamaForCausalLM`, keep `max_new_tokens` low for the first test too. The KV cache grows as the sequence gets longer, so a model that loads successfully can still run out of memory during generation. That’s why lowering the batch size helped in the FAIR example. It reduces memory used during inference. Loading in FP16 reduces the memory needed for the weights.
