How Cloud GPU & VRAM Sizing Math Works
Deploying machine learning models in the cloud requires calculating memory across three distinct components: Model Weights, Dynamic KV Cache, and Runtime CUDA & Activation Overhead.
Where accounts for PyTorch CUDA context initialization (1.2 GB baseline) plus intermediate layer activations (a 15% to 20% safety margin to prevent Out-Of-Memory / OOM crashes).
1. Parameter Footprint & Model Weights
Static MemoryModel weights scale directly with precision bits per parameter. Once loaded into GPU memory, weight tensors occupy a constant baseline memory footprint:
Example: A 70B parameter model in standard 16-bit FP16 precision consumes (70.6 × 109 × 2) / (10243) = 131.5 GB in raw weight tensors.
2. Key-Value (KV) Cache Scaling
Dynamic MemoryDuring autoregressive generation, Key and Value attention tensors accumulate across all transformer layers for every active token in context. Long context lengths (32k to 128k) and concurrent batch streams often demand 20 GB to 60 GB of additional VRAM beyond raw model weights:
Where is the number of transformer layers, is the number of KV attention heads (Grouped-Query Attention), is the head dimension (typically 128), is the context length in tokens, is concurrent batch streams, and is bytes per element (2 bytes for FP16, 1 byte for FP8 KV cache).
3. Activation & CUDA Overhead
Runtime BufferPyTorch memory pooling, CUDA kernel workspace, and attention activation matrices require a 15% to 20% safety buffer over static weights and KV cache to prevent Out-Of-Memory (OOM) termination under peak concurrency:
Serving engines (such as vLLM, SGLang, and TensorRT-LLM) manage this buffer via PagedAttention to eliminate memory fragmentation and maintain maximum GPU throughput.
4. Fine-Tuning & Training Memory (Full vs LoRA vs QLoRA)
Training WorkloadsTraining requires substantially more memory than inference due to optimizer states, gradients, and forward-pass activation checkpoints:
Full fine-tuning requires 16 to 18 GB of VRAM per billion parameters because 32-bit AdamW maintains FP32 master weights, first momentum, and second variance tensors. Parameter-efficient fine-tuning (PEFT) like LoRA freezes base weights in 16-bit, while QLoRA compresses base weights to 4-bit NormalFloat (0.5 GB/B) with paged optimizers, allowing 70B fine-tuning on a single 80 GB GPU.
Frequently Asked Questions
How accurate are the cloud GPU pricing estimates?
Should I use Spot or On-Demand instances for model serving?
Why does fine-tuning require so much more VRAM than inference?
Can I run a 70B model on a single GPU?
How does Key-Value (KV) cache scaling affect VRAM during long-context generation?
What is the difference between VRAM sizing for Dense models vs Mixture of Experts (MoE)?
Need in-depth architectural comparisons?
Check out our specific hardware guides: LLM VRAM Sizing Guide, Fine-Tuning Hardware Requirements, Diffusion & Image Gen Sizing, Qwen Hardware Sizing, DeepSeek Hardware Guide, Cost Optimization Guide, or browse the interactive GPU Cloud Lookup Index.