Build with AI

How much memory does an AI model need, and will it fit on your machine?

Written as of · Published · By Robert Scales, with AI tools · 5 min read

Short answer

Multiply the parameters in billions by the bits per weight, then divide by 8, and you get the file size in gigabytes. Add room for context and the operating system, then compare the total with the memory your graphics processor can really use, which on shared-memory machines is less than the amount installed.

Whether a model will run on your computer is mostly arithmetic. A model is a very long list of numbers called parameters, and the size of the list is known before you download anything.

The setup guide gives a short table for common sizes. This article gives you the method, so you can check any model.

The formula

def size_gb(params_billions, bits_per_weight):
    return params_billions * bits_per_weight / 8

print(size_gb(27, 4.9))   # about 16.5 GB
print(size_gb(70, 4.9))   # about 42.9 GB

There are 8 bits in a byte, which is where the division comes from. The bits per weight depend on the quantization, the compression level of the file. The llama.cpp project measures these on Llama 3.1 8B: about 16 bits for F16, 8.5 for Q8_0, 5.7 for Q5_K_M, 4.89 for Q4_K_M and 3.16 for Q2_K.

The formula holds up. It gives 4.9 GB for the 8B model at Q4_K_M, and llama.cpp reports 4.9 GB. For 70B it gives 42.9 GB against a real 43.1 GB, and for 405B about 248 GB against a real 249.1 GB.

Memory against model size

These are calculated from the formula, rounded, for the weights alone:

Parameters3.2 bits (Q2_K)4.9 bits (Q4_K_M)8.5 bits (Q8_0)16 bits (F16)
3B1.2 GB1.8 GB3.2 GB6 GB
8B3.2 GB4.9 GB8.5 GB16 GB
14B5.5 GB8.6 GB15 GB28 GB
27B11 GB17 GB29 GB54 GB
70B28 GB43 GB74 GB140 GB
120B47 GB74 GB128 GB240 GB
405B160 GB248 GB430 GB810 GB

And here are real measured or published sizes to compare against:

ModelBuildSizeSource of the figure
gpt-oss-20bMXFP414 GBOllama library
Qwen3.8-27B4-bit18 GBOllama library
Qwen3.8-27BUD-Q4_K_XL17.6 GB in memoryFramework, September 2026
Qwen3.5-122B-A10BQ3_K_S52.5 GB in memoryFramework
gpt-oss-120bMXFP465 GBOllama library
DeepSeek V4 FlashUD-IQ2_XXS90.9 GB in memoryFramework
DeepSeek V4.1 FlashQ2163 GB in memoryFramework

Models that read pictures carry an extra encoder, so their downloads run a little larger than the sum suggests.

What you can really use

The installed number is rarely the usable number.

HardwareInstalledAvailable to the model
Graphics card16, 24 or 32 GBNearly all of it, less what the display and the runtime take
AMD Ryzen AI Max+ 395 on Windows128 GBUp to 96 GB set aside as graphics memory, after a restart
AMD Ryzen AI Max+ 395 on Windows64 GBUp to 48 GB
NVIDIA RTX Spark laptop on Windows128 GBA ceiling of 110 GB on one unit, as StorageReview read it from a screenshot
Apple silicon MacAnyCapped by macOS by default; the cap can be raised

Community guides put the Mac default near 70% to 75%, a figure the MLX LM documentation does not state. That documentation does say a large model that fits in RAM can often be sped up by raising the limit with sudo sysctl iogpu.wired_limit_mb=N. Leave enough for macOS and your apps if you do.

Then add context

The context window is what the model keeps in view: your question, the conversation and any documents. It takes memory that the file size does not show, and how much depends on the model. Ollama notes that a larger context raises memory use, and it sets its default from your VRAM: about 4,000 tokens below 24 GiB, 32,000 up to 48 GiB and 256,000 above that. It recommends at least 64,000 for agents and coding tools. If several requests run at once, Ollama's memory need scales with the number of parallel requests times the context length.

Here is a planning sum for a Qwen3.8-27B coding setup on a 32 GB machine, where the 30% margin is our own rule of thumb rather than a published standard:

  1. Weights: 18 GB, from the download page.
  2. Margin for context and runtime: 30% of 18 GB, about 5.4 GB.
  3. Total: about 23.4 GB.
  4. Left for the system and apps out of 32 GB: about 8.6 GB. It should work, with little room for much else.

To check, load the model and run ollama ps, which shows the memory in use and how it splits between graphics processor and CPU. Anything other than 100% GPU means you are over budget.

Try it: Pick three models from a download page. Calculate each size with the formula, compare it with the listed size, then work out which fit your own usable memory after a 30% margin.

Prompt
Here is my hardware: [graphics card or Mac model, installed memory, operating system]. Here are the models I am considering, with their parameter counts and download sizes: [list]. For each one, calculate the weights in GB, add a 30% margin, and say whether it fits my usable memory. Show the arithmetic. If you do not know how much of my memory the graphics processor can use, say so instead of guessing.

Why does a model that should fit still run slowly?

Fitting and being fast are separate questions. Speed depends on memory bandwidth, because the processor has to read through the active parameters for every token it writes. So 128 GB of slower shared memory can load a large model and still crawl. LMSYS measured a DGX Spark, with 273 GB/s, at 2.7 tokens per second on Llama 3.1 70B. That is roughly two words per second, usable for a batch job but tiring in conversation.

A mixture-of-experts model, which wakes only part of itself for each token, changes the sum. gpt-oss-120b has 117 billion parameters but only 5.1 billion active at a time, so all of it must fit in memory while the speed is closer to a much smaller model's. The mixture-of-experts explainer covers the design.

The last cause is spill-over: when a model does not fully fit, the remainder runs on the CPU and holds everything back. If speed collapses, check that first, then lower the context or move to a smaller model.

Sources

  1. llama.cpp: quantize (README) — ggml-org (GitHub), June 5, 2026
  2. Framework Desktop — Framework
  3. Context length — Ollama (documentation)

Sources for the articles linked in the text

Each linked article has its own page, with its sources and its date.

From the Guide to Artificial Intelligence, by Robert Scales, published by Holistic Hybrid Inc. Share and adapt it under CC BY-NC-SA 4.0: credit the guide, link to https://guidetoartificialintelligence.com/en/learn/vram-calculator-which-model-fits/, no commercial use without permission, and keep the same licence.

Get the free Guide to Artificial Intelligence

Sign up for the newsletter and receive the free guide: what changed in AI, one lesson, one prompt to try. Unsubscribe in one click.

How we handle your address

Back to top

Display

Your choices are saved in this browser only. No data is sent.

Text size
100%
Colours
Reading
More settings
Accessibility statement

Get the app

Add the guide to your home screen. It opens like an app, and the pages you have read stay available offline.

Read without a connection: download the articles

iPhone and iPad (Safari, Chrome, Edge)

  1. Tap the Share button (the square with an arrow). In Chrome and Edge, it is in the address bar or the menu.
  2. Choose “Add to Home Screen”.
  3. Tap “Add”.

Android (Chrome, Edge, Samsung Internet, Firefox)

  1. Open the browser menu (⋮ or ☰).
  2. Choose “Install app” or “Add to Home screen”.
  3. Confirm with “Install”.

Computer (Chrome, Edge)

  1. Click the install icon at the right end of the address bar, or open the browser menu (⋮ or …).
  2. In Chrome, choose “Cast, save and share”, then “Install page as app”. In Edge, choose “Apps”, then “Install this site as an app”.
  3. Click “Install”.

Mac (Safari)

  1. Open the File menu.
  2. Choose “Add to Dock”.
  3. Click “Add”.

Firefox on a computer can’t install a site as an app. Use Chrome, Edge or Safari instead.