Fine-Tuning GPU VRAM Sizer

Calculate exact GPU memory requirements for LoRA, QLoRA, and Full Fine-Tuning across open LLMs.

1. Base Model & Architecture

Parameters8.03B
Hidden Dim4096
Layers32

2. Training Strategy & Optimization

3. Batch & Context Hyperparameters

4,096 tokens
2
Gradient Checkpointing
Recomputes activations during backward pass (~65% RAM saved)
Estimated Peak VRAM
9.4 GB
Safe Target (+15% Headroom)10.8 GB
Trainable Parameters:29.36M (0.366% of 8.03B)
Base Weights:3.7 GB
Gradients:0.05 GB
Optimizer States:0.05 GB
Activations:4.0 GB
CUDA & Context:1.4 GB
LoRA Adapters:0.05 GB

GPU Compatibility & Sizing Matrix

NVIDIA RTX 3060(12 GB VRAM)
360 GB/s โ€ข $0.20/hr
Fits (22% Free)
NVIDIA RTX 4070(12 GB VRAM)
504 GB/s โ€ข $0.25/hr
Fits (22% Free)
NVIDIA RTX 4080(16 GB VRAM)
717 GB/s โ€ข $0.35/hr
Fits (42% Free)
NVIDIA RTX 3090 / 4090(24 GB VRAM)
1,008 GB/s โ€ข $0.50/hr
Fits (61% Free)
NVIDIA A10G / L4(24 GB VRAM)
600 GB/s โ€ข $0.80/hr
Fits (61% Free)
NVIDIA L40S(48 GB VRAM)
864 GB/s โ€ข $1.40/hr
Fits (81% Free)
NVIDIA A100 PCIe(40 GB VRAM)
1,555 GB/s โ€ข $1.60/hr
Fits (77% Free)
NVIDIA A100 SXM4(80 GB VRAM)
2,039 GB/s โ€ข $2.20/hr
Fits (88% Free)
NVIDIA H100 SXM5(80 GB VRAM)
3,350 GB/s โ€ข $3.50/hr
Fits (88% Free)
Apple M-Series (36GB Unified)(36 GB VRAM)
150 GB/s โ€ข Local Mac/hr
Fits (74% Free)
Apple M-Series (64GB Unified)(64 GB VRAM)
300 GB/s โ€ข Local Mac/hr
Fits (85% Free)
Apple M-Series (128GB Unified)(128 GB VRAM)
800 GB/s โ€ข Local Mac/hr
Fits (93% Free)
Training Recipe (YAML)
# Fine-Tuning Recipe for Llama 3.1 8B
base_model: Llama 3.1 8B
training_method: QLORA
precision: 4bit
optimizer: adamw8bit
sequence_len: 4096
micro_batch_size: 2
gradient_checkpointing: true
lora_r: 16
lora_alpha: 32
lora_target_modules: [q_proj, k_proj, v_proj, o_proj, gate_proj, up_proj, down_proj]

# Peak VRAM Estimate: 9.4 GB (Safe Target: 10.8 GB)

Understanding GPU VRAM Allocation During LLM Fine-Tuning

Fine-tuning Large Language Models (LLMs) requires substantially more GPU video memory (VRAM) than simple inference. While running inference on a 7B model in 4-bit only consumes ~5 GB of VRAM, fine-tuning introduces several major memory consumers:

Key Memory Consumers in Deep Learning Training

  • Model Weights: In FP16/BF16, each parameter takes 2 bytes (e.g., an 8B model takes ~16 GB). In 4-bit NormalFloat (QLoRA), the base model is compressed down to 0.5 bytes per parameter (~4 GB for 8B).
  • Optimizer States: Standard 32-bit AdamW stores 2 states per trainable parameter (first momentum $m_t$ and second momentum $v_t$) in 32-bit float, taking 8 bytes per trainable parameter. Using 8-bit AdamW (bitsandbytes) reduces this to 2 bytes per parameter.
  • Gradients: Backpropagation computes and stores gradients in 16-bit float (2 bytes per trainable parameter).
  • Activations: Intermediate tensors generated during the forward pass and held until backpropagation. Activation memory scales linearly with sequence length ($S$), batch size ($B$), and number of layers ($L$). Enabling Gradient Checkpointing discards intermediate activations and recomputes them on the fly during the backward pass, reducing activation memory by ~60% to 75% at the cost of ~20% slower training throughput.
  • CUDA Framework Buffer: PyTorch and CUDA runtime allocate internal workspace buffers and memory fragmentation buffers (~1.2 GB to 2.5 GB).

Training Strategy Comparison

  • QLoRA (Quantized Low-Rank Adaptation): Freezes the base model in 4-bit NF4 and trains small low-rank adapter matrices in 16-bit. Allows fine-tuning an 8B model on a single consumer GPU with 12GBโ€“16GB VRAM (e.g. RTX 3060 / 4070 / 4080).
  • LoRA (Low-Rank Adaptation): Keeps the base model in 16-bit BF16/FP16 without quantization, training only low-rank adapter weights. Requires ~24GB VRAM (e.g. RTX 3090/4090 or A10G) for 8B models.
  • Full Fine-Tuning: Updates 100% of the model weights, gradients, and optimizer states. For a 70B parameter model, full fine-tuning requires multi-GPU distributed clusters (e.g. 8x A100/H100 80GB with DeepSpeed ZeRO-3 or FSDP).