AI 推理显存与显卡估算器

基于模型参数量、精度与上下文长度估算大语言模型在 GPU 上的显存占用与显卡需求下界。接收层数、隐藏维度、注意力头数与量化选项,输出权重、KV 缓存与推荐显存容量评估。本工具基于显存理论公式估算,实际推理吞吐受显存带宽与服务框架算子实现影响。

先估算显存容量,再讨论推理性能

权重是否装得下、KV 缓存有多大、需要几张卡和能生成多快,是不同问题。本工具先给理想分片条件下的容量下界;仅在你明确提供算力、带宽和效率假设后,才输出稠密模型的解码性能情景。

操作步骤

  1. 选择模型和显卡预设,核对来源与型号;也可手动修改总参数、层数、KV 头数、头维度和每卡显存。
  2. 设置权重与 KV 精度、总缓存长度、并发数、每卡运行开销和余量。MoE 按总参数存权重,按激活参数估算参数矩阵运算量。
  3. 先检查容量结果。若要探索速度情景,补充实际精度的稠密算力和效率假设;还应在真实框架与互联环境中验证。

Qwen2.5 7B 的单序列容量规划

输入

7.61B 参数;28 层;4 KV 头;头维度 128;缓存 4096;并发 1

选项

权重 16 bit;KV 16 bit;权重开销 10%;每卡 24 GiB;每卡运行开销 2 GiB;预留 10%

输出 / 解析结果

权重约 15.59 GiB;KV 约 0.22 GiB;扣除开销后每卡可用约 19.60 GiB;理想容量下界为 1 张卡

限制与常见问题

  • 容量下界不等于可部署配置,特别是跨卡分片、注意力头可整除与通信效率仍需核对。不包含 CPU 卸载、训练或微调。
  • 性能情景不预测预填充时延、长上下文注意力额外运算或实际互联流量。稀疏峰值、FP16 和 INT8 指标不能混用。
  • MoE、MLA、循环、滑动窗口与混合架构不能套用统一缓存/速度假设;首版 MoE 不输出性能速度。GPU 和模型数据不是实时目录。

Estimate memory capacity before discussing inference speed

Weight capacity, KV size, GPU count and generation speed are separate questions. This tool first reports a capacity lower bound assuming ideal sharding. Dense-model decode scenarios require explicit compute, bandwidth and efficiency assumptions.

Steps

  1. Choose a model/GPU preset and check its sources and exact variant, or edit total parameters, layers, KV heads, head dimension and per-GPU memory.
  2. Set weight/KV precision, total cached context, concurrency, per-GPU overhead and reserve. MoE storage uses total parameters; parameter-matrix arithmetic uses active parameters.
  3. Review capacity first. For a speed scenario, supply dense throughput for the actual precision and efficiency assumptions, then validate using the real framework and interconnect.

Single-sequence Qwen2.5 7B capacity planning

Input

7.61B parameters; 28 layers; 4 KV heads; head dimension 128; cached context 4096; concurrency 1

Options

16-bit weights and KV; 10% weight overhead; 24 GiB/GPU; 2 GiB runtime overhead/GPU; 10% reserve

Output / inspection

Approximately 15.59 GiB weights, 0.22 GiB KV and 19.60 GiB usable per GPU; ideal capacity lower bound: 1 GPU

Limits and common issues

  • A capacity bound is not a validated deployment. Check sharding, head divisibility and communication, especially across GPUs. CPU offload, training and fine-tuning are excluded.
  • The speed scenario does not predict prefill latency, extra long-context attention arithmetic or actual link traffic. Do not mix sparse peaks, FP16 and INT8 figures.
  • Uniform cache/speed assumptions do not cover MoE, MLA, recurrent, sliding-window or hybrid architectures. MoE speed is not reported in this version. Preset data is not a live catalog.