RUNLOCALAIv38
->Will it run?Best GPUCompareTroubleshootStartLearnPulseModelsHardwareToolsBench
Run check
RUNLOCALAI

Independently operated catalog for local-AI hardware and software. Hand-written verdicts. Source-cited claims. Reproducible commands when we have them.

OP·Fredoline Eruo
DIR
  • Models
  • Hardware
  • Tools
  • Benchmarks
TOOLS
  • Will it run?
  • Compare hardware
  • Cost vs cloud
  • Choose my GPU
  • Prompting kits
  • Quick answers
REF
  • All buyer guides
  • Learn local AI
  • Methodology
  • Glossary
  • Errors KB
  • Trust
EDITOR
  • About
  • Author
  • How we make money
  • Editorial policy
  • Contact
LEGAL
  • Privacy
  • Terms
  • Sitemap
MAIL · MONTHLY DIGEST
Get monthly local AI changes
Monthly recap. No spam.
DISCLOSURE

Some links on this site are affiliate links (Amazon Associates and other first-class retailers). When you buy through them, we earn a small commission at no extra cost to you. Affiliate links do not influence our verdicts — there are cards we rate highly that we don't have affiliate relationships with, and cards that sell well that we refuse to recommend. Read more →

© 2026 runlocalai.coIndependently operated
RUNLOCALAI · v38
  1. >
  2. Home
  3. /Learn
  4. /How-to
  5. /How to measure memory usage during model inference
HOW-TO · INF

How to measure memory usage during model inference

intermediate·10 min·By Fredoline Eruo
Target environment
Ubuntu 24.04 · Ollama 0.4.x
PREREQUISITES

NVIDIA GPU with nvidia-smi installed, or AMD GPU with rocm-smi installed, plus a running inference session

What this does

Captures GPU and system RAM consumption before, during, and after model inference, producing baseline and peak memory readings. The end state is a clear record of how much memory a model consumes at rest and under load.

Steps

  1. Capture baseline GPU memory before inference. Checks free VRAM with no model loaded.

    nvidia-smi --query-gpu=memory.used,memory.free,memory.total --format=csv,noheader,nounits
    

    Expected output: 450, 7361, 7808 (Used: 450 MiB, Free: 7361 MiB, Total: 7808 MiB).

  2. Load the model and measure GPU memory during inference. Opens a second terminal while the model generates output.

    nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits
    

    Expected output: A value higher than baseline, e.g. 1850 MiB used under load.

  3. Check system-wide RAM with free. Verifies host RAM consumption alongside GPU usage.

    free -h
    

    Expected output: Total, used, and available memory across Mem and Swap rows.

  • Record the local run evidence. Save the exact command, runtime or package version, model name if applicable, and observed output so the result can be reproduced later.

Verification

nvidia-smi --query-gpu=memory.used --format=csv,noheader,nounits
# Expected: value exceeds baseline from step 1 by at least the model size

Common failures

  • nvidia-smi not found: NVIDIA driver not installed or not in PATH; install the driver and confirm with which nvidia-smi.
  • model still loading: Wait for the model to finish loading before measuring; initial VRAM spikes during KV cache allocation.
  • memory reported as zero: Inference runtime may be running on CPU only; verify GPU selection in the runtime config.
  • baseline and peak identical: Model is running on CPU only; check CUDA visibility with nvidia-smi directly.
  • process not found: Ollama process may run under a different user; check with sudo ps aux | grep ollama.

Related guides

  • How to benchmark first-token latency for interactive applications
  • How to benchmark models with varying context lengths
RELATED GUIDES
INF
How to benchmark first-token latency for interactive applications
INF
How to benchmark models with varying context lengths
← All how-to guidesCourses →