CHAPTER 02 OF 12
Know your hardware and memory budget
Separate storage, working memory and actual runtime compatibility.
In this chapter
Three resources that are easy to confuse
Storage holds the downloaded files. Working memory holds weights, intermediate values and runtime state while a request runs. Compute performs the operations that generate output. A computer can have enough storage for a file and still be unable to load it, or have enough memory yet generate too slowly for the intended application.
On many discrete GPU systems, GPU memory and system RAM are separate budgets. On Apple Silicon, the CPU and GPU share physical memory, but the operating system and other applications need some of it too. An iPhone also has process limits and changing memory pressure. Treat the total installed memory as an upper bound, not an allocation promised to your model.
Units matter. One decimal GB is 1,000,000,000 bytes; one GiB is 1,073,741,824 bytes. A file shown as about 398 MB can therefore appear as roughly 379 MiB in another tool. That difference is unit conversion, not necessarily a corrupted download. Keep exact byte counts when identifying artifacts.
Build a budget with uncertainty
A rough weight-only calculation is parameters multiplied by average bits per weight, divided by eight. Actual files also contain metadata and tensors with different precision. Runtime memory adds caches, buffers and bookkeeping. Longer context and multiple simultaneous requests can increase the working set substantially. Do not turn the weight-only calculation into a promise that the whole application will fit.
The shared starter record deliberately leaves total memory requirements unknown. We have measured successful execution on specific configurations, but that does not establish a universal minimum. During a new test, close unrelated memory-heavy applications, begin with a small context and watch actual behavior. If the runtime refuses to load, choose a smaller supported artifact before repeatedly forcing the same failure.
Prerequisites
Use your own machine and a terminal. The measured commands in this section are for macOS. The companion inventory also reports operating-system and Python information elsewhere, but Windows and Linux were not exercised for this edition.
Steps
On a Mac, open System Settings and read the chip and installed memory. Record them instead of relying on browser GPU detection.
In Terminal, inspect physical memory and free space:
sysctl -n hw.memsize
df -h .Complete chapter 4, then run:
python3 rtm_lab.py inventory --output hardware.jsonCompare the operating system and runtime in the report with the book's reference environment. Free space changes; it is not part of a permanent machine specification.
While generating a response, inspect Activity Monitor's memory pressure and the runtime's loaded models:
OLLAMA_HOST=127.0.0.1:11435 ollama psRecord whether the application remained responsive. A memory estimate that fits on paper is incomplete if the machine spends its time swapping or repeatedly unloading the model.
Expected results
The Mac used for this edition reports 25,769,803,776 bytes of physical memory, which is 24 GiB. Your result should reflect your machine. ollama ps may be empty before a request or after the model unloads. A successful request followed by a loaded entry demonstrates that configuration at that time.
Common failures
Do not infer a chip from RAM capacity or use the largest RAM option ever sold for that chip. Leave unknown hardware facts unknown. If disk space is low, identify files you own before deleting anything; runtime caches and partial downloads may occupy more than the finished model file. If memory pressure rises, reduce context or choose a smaller model, then measure again.
Exercise
Write a resource budget with four lines: exact file bytes, free disk space, installed memory, and observed runtime behavior. Add one uncertainty you cannot resolve yet. Repeat after one change and explain which observation changed.
Sources
Ollama GPU support describes runtime-specific hardware support. The Ollama FAQ documents loaded-model inspection and configuration. Neither replaces a measurement on your machine.