hf-mem estimates the memory required to run any model from the Hugging Face Hub, or from a local path, without downloading the weights. It reads the Safetensors, GGUF and ONNX metadata via HTTP Range requests, and only depends on httpx2.
The estimate covers the model weights, the KV cache for generative models, and the runtime overhead of the inference engine (activations, encoder, graphs and runtime), for Transformers, Diffusers, Sentence Transformers, GGUF and ONNX models (without the ONNX Runtime overhead).
Usage
Run it with uv as uvx hf-mem <model>, where <model> is a Hugging Face Hub model ID (optionally with @revision, and with :<quantization> for GGUF), a URL, or a local path. Use --gpu-memory to check whether the model fits and --help for all options.
Transformers
$ uvx hf-mem zai-org/GLM-5.3-Flash
┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬ hf-mem v1.1.2 ┐
├┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┤
│ INFERENCE MEMORY ESTIMATE FOR │
│ https://hf.co/zai-org/GLM-5.3-Flash @ main │
│ w/ max-model-len=1048576, batch-size=1 │
├─────────────────┬─────────────────────────────────────┤
│ GPU CAPACITY │ 365.20 GiB (392.13 GB) ON ONE GPU │
│ RECOMMENDED │ ███████████████████████████████████ │
├─────────────────┴─────────────────────────────────────┤
│ MODEL (9.67B PARAMS, 15.46 GiB) │
├─────────────────┬─────────────────────────────────────┤
│ BF16 │ 12.90 / 365.20 GiB │
│ 6.93B PARAMS │ █▎░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┼─────────────────────────────────────┤
│ F8_E4M3 │ 2.55 / 365.20 GiB │
│ 2.74B PARAMS │ ▎░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┼─────────────────────────────────────┤
│ F32 │ 0.00 / 365.20 GiB │
│ 295.52K PARAMS │ ▏░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┴─────────────────────────────────────┤
│ EXPERTS (288 x 1.08B PARAMS, 290.32 GiB) │
├─────────────────┬─────────────────────────────────────┤
│ F8_E4M3 │ 290.25 / 365.20 GiB │
│ 311.65B PARAMS │ ███████████████████████████▉░░░░░░░ │
├─────────────────┼─────────────────────────────────────┤
│ F32 │ 0.07 / 365.20 GiB │
│ 0 PARAMS │ ▏░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┴─────────────────────────────────────┤
│ KV CACHE (1048576 TOKENS, 17.35 GiB) │
├─────────────────┬─────────────────────────────────────┤
│ BF16 │ 17.35 / 365.20 GiB │
│ 1048576 TOKENS │ █▋░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┴─────────────────────────────────────┤
│ OVERHEAD (5.55 GiB) │
├─────────────────┬─────────────────────────────────────┤
│ ACTIVATIONS │ 3.48 / 365.20 GiB │
│ │ ▍░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┼─────────────────────────────────────┤
│ ENCODER │ 0.05 / 365.20 GiB │
│ │ ▏░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┼─────────────────────────────────────┤
│ GRAPHS │ 0.89 / 365.20 GiB │
│ │ ▏░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┼─────────────────────────────────────┤
│ RUNTIME │ 1.13 / 365.20 GiB │
│ │ ▏░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
└─────────────────┴─────────────────────────────────────┘
Generative models default to the context length in config.json and one sequence. Set --max-model-len, --batch-size and --kv-cache-dtype (e.g. fp8) to estimate your workload; automatic cache precision follows the model config.
$ uvx hf-mem Qwen/Qwen3.8-27B --max-model-len 32768 --batch-size 4
┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬ hf-mem v1.1.2 ┐
├┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┤
│ INFERENCE MEMORY ESTIMATE FOR │
│ https://hf.co/Qwen/Qwen3.8-27B @ main │
│ w/ max-model-len=32768, batch-size=4 │
├─────────────────┬───────────────────────────────────┤
│ GPU CAPACITY │ 73.71 GiB (79.14 GB) ON ONE GPU │
│ RECOMMENDED │ █████████████████████████████████ │
├─────────────────┴───────────────────────────────────┤
│ MODEL (27.36B PARAMS, 50.96 GiB) │
├─────────────────┬───────────────────────────────────┤
│ BF16 │ 50.96 / 73.71 GiB │
│ 27.36B PARAMS │ ██████████████████████▉░░░░░░░░░░ │
├─────────────────┴───────────────────────────────────┤
│ KV CACHE (131072 TOKENS, 9.19 GiB) │
├─────────────────┬───────────────────────────────────┤
│ BF16 │ 9.19 / 73.71 GiB │
│ 131072 TOKENS │ ████▏░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┴───────────────────────────────────┤
│ OVERHEAD (6.19 GiB) │
├─────────────────┬───────────────────────────────────┤
│ ACTIVATIONS │ 2.65 / 73.71 GiB │
│ │ █▏░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┼───────────────────────────────────┤
│ ENCODER │ 2.42 / 73.71 GiB │
│ │ █▏░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┼───────────────────────────────────┤
│ GRAPHS │ 0.39 / 73.71 GiB │
│ │ ▏░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
├─────────────────┼───────────────────────────────────┤
│ RUNTIME │ 0.74 / 73.71 GiB │
│ │ ▍░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ │
└─────────────────┴───────────────────────────────────┘
Diffusers
$ uvx hf-mem Qwen/Qwen-Image-2.1
┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬ hf-mem v1.1.2 ┐
├┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┤
│ INFERENCE MEMORY ESTIMATE FOR │
│ https://hf.co/Qwen/Qwen-Image-2.1 @ main │
├─────────────────┬──────────────────────────────┤
│ TOTAL MEMORY │ 30.84 GiB (16.22B PARAMS) │
│ │ ████████████████████████████ │
├─────────────────┴──────────────────────────────┤
│ TEXT_ENCODER (8.77B PARAMS, 16.33 GiB) │
├─────────────────┬──────────────────────────────┤
│ BF16 │ 16.33 / 30.84 GiB │
│ 8.77B PARAMS │ ██████████████▉░░░░░░░░░░░░░ │
├─────────────────┴──────────────────────────────┤
│ TRANSFORMER (7.12B PARAMS, 13.25 GiB) │
├─────────────────┬──────────────────────────────┤
│ BF16 │ 13.25 / 30.84 GiB │
│ 7.12B PARAMS │ ████████████░░░░░░░░░░░░░░░░ │
├─────────────────┴──────────────────────────────┤
│ VAE (337.74M PARAMS, 1.26 GiB) │
├─────────────────┬──────────────────────────────┤
│ F32 │ 1.26 / 30.84 GiB │
│ 337.74M PARAMS │ █▏░░░░░░░░░░░░░░░░░░░░░░░░░░ │
└─────────────────┴──────────────────────────────┘
Sentence Transformers
$ uvx hf-mem google/embeddinggemma-2
┌┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬┬ hf-mem v1.1.2 ┐
├┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┴┤
│ INFERENCE MEMORY ESTIMATE FOR │
│ https://hf.co/google/embeddinggemma-2 @ main │
├─────────────────┬──────────────────────────────────┤
│ TOTAL MEMORY │ 1.39 GiB (744.37M PARAMS) │
│ │ ████████████████████████████████ │
├─────────────────┴──────────────────────────────────┤
│ MODEL (744.37M PARAMS, 1.39 GiB) │
├─────────────────┬──────────────────────────────────┤
│ BF16 │ 1.39 / 1.39 GiB │
│ 744.37M PARAMS │ ████████████████████████████████ │
└─────────────────┴──────────────────────────────────┘
Text encoders, rerankers and Sentence Transformers include warmup memory. Use --max-num-batched-tokens for the warmup token budget and --max-model-len for the sequence length.