Skip to main content
Apidly Cloud
Cookie policy

Analytics and ad cookies stay off unless you accept. Cookie policy

We would like to use Google Analytics and Microsoft Clarity to understand how the public pages are used, including page views and session recordings, and the Reddit Pixel to measure whether our ads on Reddit lead to visits and sign-ups. You choose here whether they are on. Rejecting changes nothing about how the site works.

How much VRAM do you need for LLMs and images?

Work out how much GPU memory your model needs before you rent: a simple formula for language models, image models and fine-tuning, with worked examples.

Published November 25, 20265 min read

The first question before you rent a GPU is not "which one is fastest" but "will my model fit". If it does not fit in the GPU's memory (VRAM), it does not run, however fast the card is. This guide gives you a formula you can do on paper, worked examples for the three common jobs, and a way to confirm the answer with a short test before you commit to a long run.

All numbers here are rules of thumb. Real use depends on the software, the settings and the exact model, so treat the result as a starting point and leave a margin.

What takes up VRAM

Four things share the memory:

  1. Weights. The model itself. This is the biggest and the easiest part to estimate.
  2. Working memory. Activations, buffers and the framework's own overhead.
  3. The KV cache (language models only). The memory a model keeps for the text so far, for every request being served. It grows with prompt length and with the number of users at once.
  4. Training state (training only). Gradients and optimizer state, which can add several times the size of the weights.

Language models for inference

The weights need roughly:

Precision Memory per billion parameters
16-bit about 2 GB
8-bit about 1 GB
4-bit about 0.5 GB

Then add 20 to 30 percent for the framework and cache. Add more if you use very long prompts or serve many requests at the same time. Lower precision saves memory at some cost in quality, which you should test on your own task.

Worked examples with that rule:

  • 8B model at 16-bit. Weights about 16 GB, plus 25 percent is about 20 GB. A 24 GB GPU fits, for example the RTX 4090 or RTX 3090.
  • 14B model at 4-bit. Weights about 7 GB, plus margin is under 10 GB. A 12 GB or 16 GB GPU is enough for modest prompt lengths.
  • 70B model at 4-bit. Weights about 35 GB, plus 25 percent is about 44 GB. This points to a 48 GB card such as the L40S, the A40 or the RTX A6000.
  • 70B model at 16-bit. Weights about 140 GB. No single card in the usual range holds that, so you would need several GPUs and software that can split the model.

A note on several GPUs: the memory of a multi-GPU server is not one pool for every program. The software must support splitting the model across cards. The GPU memory guide explains how a configuration's VRAM is shown in total and per GPU.

Controlling the KV cache

If a model loads but then fails on long prompts, the cache is the likely cause. Two levers help: set a smaller maximum context length (in vLLM this is MAX_MODEL_LEN), and limit how many requests run at once. Both trade capacity for memory. Run an open LLM with vLLM shows where to set it.

Image and video models

Diffusion models are measured by what they need to run at a normal resolution, not by parameter count alone. Resolution, batch size and extra nodes such as upscalers all add memory. The templates in the Apidly catalogue declare a minimum, which is a good guide for the tool and starter model each one installs:

Template Minimum VRAM
Fooocus 8 GB
ComfyUI (starter model Stable Diffusion 1.5) 12 GB
Stable Diffusion WebUI Forge 12 GB

Larger models, such as SDXL-class and newer ones, generally want more than the smallest of these, and the biggest current image and video models want 24 GB or more. Check the model's own page for its requirement.

The minimum is what lets the template start. For comfortable work at higher resolutions, pick a card with spare memory, and see How to run ComfyUI on a cloud GPU. A model that needs more than the GPU has will fail with an out-of-memory error; the fix is a smaller image, a lighter model or a bigger card.

Fine-tuning

Training needs far more than inference because it also stores gradients and optimizer state.

  • Full fine-tuning updates every weight. Memory can be several times the size of the weights, so even a small model needs a large GPU, and big models need several.
  • LoRA trains a small set of extra weights on top of a frozen model. Memory is close to the model plus a small overhead.
  • QLoRA does the same on a model stored in 4-bit. This is the usual way to fit a 7B or 8B model on one 24 GB GPU, with room for the training batch.

Sequence length and batch size also matter: doubling either raises the working memory. Gradient checkpointing trades speed for memory and is worth turning on when you are close to the limit. The step-by-step LoRA fine-tuning guide uses these settings, and A checklist for your first fine-tuning run helps you plan one.

A four-step way to decide

  1. Find the model's size in billions of parameters and the precision you will use.
  2. Multiply: 2 GB per billion for 16-bit, 1 GB for 8-bit, 0.5 GB for 4-bit.
  3. Add 20 to 30 percent, more for long prompts, big batches or training.
  4. In Deploy, use the GPU memory filter to hide anything smaller, then sort by Price, low to high to find the cheapest card that fits.

Confirm with a short test

An estimate is cheap, a failed long run is not. Before you commit:

  • Start the server and run the smallest realistic job: one prompt, one image or a few training steps.
  • Run nvidia-smi in a terminal on the server and read the memory in use while the job runs. If you are near the limit, move up one size.
  • Billing is by the second, so this test costs very little. Stop the server when you have your answer. See Billing by the second, explained.

To keep an experiment from running on by accident, set an automatic stop on the server: after a running time, when the GPU is idle, or at a spending limit. Automation explains each rule.

What it costs

Larger VRAM usually means a higher hourly price, but not always in a straight line, and prices follow supply. Compare the live numbers on the pricing page or on a GPU's own page rather than relying on a figure written here. When you know what you need, create an account and start a server in the console. If you want to browse by model instead, the model pages show what fits.

Try it on a real GPU server

Create a free account and add a balance from $10. Servers are billed by the second, and the review step shows the price per hour before you request one.

Related guides