LLM Fine-Tuning VRAM Calculator
Estimate the GPU memory needed to fine-tune a large language model with full fine-tuning, LoRA or QLoRA. Pick a model, sequence length, batch size, LoRA rank and optimizer, and see weights, gradients, optimizer states and activations side by side.
Model and training settings
Training example length after padding or packing.
Sequences per forward pass, before gradient accumulation.
Used by LoRA and QLoRA. Common values: 8 to 64.
Weights and gradients. Applies to full fine-tuning only.
Fragmentation and buffers, on top of a fixed 1 GiB CUDA context.
Estimated VRAM for Llama 3.1 8B
| GB | Full fine-tune | LoRA | QLoRA (4-bit) |
|---|---|---|---|
| Model weights | 15.0 | 15.0 | 3.9 |
| Gradients | 15.0 | 0.2 | 0.2 |
| Optimizer states | 59.8 | 0.3 | 0.3 |
| LoRA adapter weights (fp32) | 0.0 | 0.2 | 0.2 |
| Activations and logits | 2.7 | 2.7 | 2.7 |
| Overhead | 10.2 | 2.8 | 1.7 |
| Total VRAM | 103 GB | 21.1 GB | 8.9 GB |
| Trainable parameters | 8.03B | 41.9M | 41.9M |
Memory is in GiB (1024³ bytes) per GPU, for a single device with no offloading. See the assumptions below.
Which GPUs can do it?
QLoRA (4-bit) needs about 8.9 GB.
| GPU | Fits on one card? | Minimum GPUs (ideal sharding) |
|---|---|---|
| RTX 4060 Ti / 4070 Ti (16 GB) | Yes | 1 |
| RTX 3090 / 4090 (24 GB) | Yes | 1 |
| RTX 5090 (32 GB) | Yes | 1 |
| L40S / RTX A6000 (48 GB) | Yes | 1 |
| A100 / H100 (80 GB) | Yes | 1 |
| H200 (141 GB) | Yes | 1 |
Multi-GPU counts assume FSDP or DeepSpeed ZeRO-3 splits weights, gradients, optimizer states and activations evenly with 5% reserved per card. Real runs need extra for communication buffers.
How to estimate fine-tuning VRAM
- Choose a model preset, or Custom and paste the values from its
config.json. - Set the sequence length and micro-batch size you will train with. Gradient accumulation does not add memory.
- Pick a LoRA rank, the target modules and the optimizer. Turn gradient checkpointing on or off.
- Read the table: the left-most column that fits your GPU is the most thorough method you can run.
Assumptions
- Full fine-tune: every parameter is trained. Weights and gradients at 2 bytes (bf16) or 4 bytes (fp32), plus optimizer states at 8 bytes per parameter for AdamW (two fp32 values), 2 for 8-bit AdamW or 4 for SGD with momentum.
- LoRA: base weights frozen in bf16 (2 bytes per parameter). Adapter weights, their gradients are fp32 (4 bytes each), and the optimizer states use the chosen optimizer on the adapter parameters only. Adapter size is rank × (input + output size) for each targeted layer.
- QLoRA: as LoRA, but the frozen base is NF4 with double quantization, about 0.516 bytes per parameter. Embedding and output layers are not treated separately, which can add 1 GB or more for large vocabularies.
- Activations: bf16 with FlashAttention-style kernels (no sequence-squared term), about 34 × hidden-size bytes per token per layer, or 2 × hidden size bytes per token per layer with gradient checkpointing plus one layer recomputed. fp32 logits and their gradient add 8 bytes per vocabulary entry per token.
- Overhead: a percentage you set (default 10%) plus a fixed 1 GiB for the CUDA context. No CPU offload, no paged optimizers and no sequence packing effects.
- Treat results as a planning estimate, roughly ±20%. Real use varies with the framework, kernels and padding.
Worked example
Llama 3.1 8B at 2,048 tokens, batch 1, checkpointing on, rank 16 on all linear layers and AdamW: LoRA adds 41.9 million trainable parameters (0.5%), and the total is about 21 GB (QLoRA about 9 GB, full fine-tuning about 100 GB).
After training, check what it takes to run the model with the LLM RAM and VRAM calculator and size the serving cache with the KV cache calculator. Count the tokens in your dataset with the AI tokens calculator.
Updated November 19, 2026. Not financial advice. This calculator is for education and rough estimates only. It relies on simplified models and your inputs, ignores taxes and many real-world costs, and past or modelled results do not guarantee future outcomes. Consult a licensed professional before making financial decisions.
See also
- Planning to run the model after training? Check inference memory with the LLM RAM and VRAM calculator.
- Size the serving-time cache with the KV cache calculator.
- Estimate GPU-hours and dollars for the run with the LLM training cost calculator.
- Count the tokens in your training data with the AI tokens calculator.
Frequently Asked Questions (FAQ)
It depends on the method. With the default settings (2,048-token sequences, batch 1, gradient checkpointing) Llama 3.1 8B needs about 9 GB with QLoRA, about 21 GB with LoRA and about 100 GB for a full fine-tune with AdamW. Llama 3.1 70B needs about 47 GB with QLoRA, which fits one 80 GB card.
Full fine-tuning trains every weight, so you store a gradient and two optimizer values for each one. With bf16 weights and AdamW that is 2 + 2 + 8 = 12 bytes per parameter, six times the size of the weights alone. LoRA freezes the base model and only trains small adapter matrices, so gradients and optimizer states are tiny.
Both train small low-rank adapters on a frozen model. LoRA keeps the frozen base weights in 16-bit. QLoRA stores them in 4-bit NF4, roughly a quarter of the size, and de-quantizes them on the fly. That cuts weight memory by about 75% at the cost of slower steps and a small quality difference.
Total = frozen or trainable weights + gradients + optimizer states + LoRA adapters + activations + overhead. Weights are parameters × bytes per parameter, optimizer states are 8 bytes per trainable parameter for AdamW, and activations are about 34 × hidden-size bytes per token per layer in bf16 (2 × hidden size with gradient checkpointing). The full list of assumptions is on the page.
Very little. Rank 16 on all linear layers of Llama 3.1 8B adds about 42 million trainable parameters (0.5% of the model), roughly 0.6 GB with gradients and optimizer states. Rank 64 is four times that, still small next to the base weights.
It discards most intermediate activations during the forward pass and recomputes them during the backward pass. Activation memory drops sharply, especially for long sequences and large batches, for roughly 20–30% more compute per step.
Activation memory grows linearly with sequence length × batch size, and so do the output logits, which can be several GB for models with big vocabularies. Weights, gradients and optimizer states do not change, so a long context hurts most on small models and when checkpointing is off.
Yes. FSDP and DeepSpeed ZeRO-3 shard weights, gradients and optimizer states across GPUs, so the total is split roughly evenly plus communication buffers. The “GPUs needed” column assumes perfect sharding, so treat it as a minimum.
Frameworks differ in how they cache, pad and fragment memory, and attention kernels, packing, fused losses and CPU offload all change the numbers. Treat the result as a planning figure within roughly ±20%, and leave headroom before renting a GPU.
Not during training: the whole sequence is processed at once and the activations above cover it. The KV cache matters when you serve the model afterwards. Use the KV cache calculator and the LLM RAM calculator for inference.
Related Tools
- LLM VRAM CalculatorEstimate how much GPU memory (VRAM) you need to run a local LLM, and which GPUs can run it.
- KV Cache CalculatorMemory per token and total KV cache from layers, KV heads, head dimension, context, batch and precision, with GQA and context-length views.
- AI Token CounterCount tokens, words and characters in your prompts for GPT, Claude, Gemini and Llama.
- GPU Rental Cost CalculatorEstimate cloud GPU cost per job and per month from hourly rate, GPU count, job and idle hours, storage and egress. Example rates are dated and editable.