Local Deployment of Multimodal Large Models: Multi-GPU VRAM Planning Practices
This article provides a practical guide for the local deployment of multimodal large models, focusing on multi-GPU VRAM planning. It covers key considerations such as inference framework support, quantization strategies, and compute backends, followed by a detailed approach to capacity planning and multi-GPU configuration to ensure a stable and efficient deployment.
1. Why Deploy Multimodal Large Models Locally?
Calling cloud APIs is the fastest way to access large models, but local deployment remains valuable in scenarios requiring data privacy, offline availability, and controllable costs. Multimodal models simultaneously accept text, image, and even video inputs, making them more challenging to deploy than text-only models. The difficulties mainly lie in three areas: varying progress in inference framework support for new architectures, massive model weight sizes, and the need for additional weights and inference paths for the visual components.
Using a complete local deployment process as a guide, this article abstracts reusable engineering methods applicable to the implementation of similar models.
2. Three Dimensions of Selection
2.1 Inference Framework Support for Target Architectures
During the early release phase of a new model, the main branches of mainstream inference frameworks often do not yet include the corresponding model structure. In such cases, you can opt for community-maintained edge branches. Before selecting one, confirm three things: whether the branch implements the target model’s attention structure and weight mapping, whether it supports the required multimodal input paths, and whether the branch is actively updated. Edge branches typically have poorer stability; for production environments, you should lock to a specific commit version to prevent upstream changes from causing model behavior drift.
2.2 Quantization Strategy: Precision vs. Size
Quantization compresses model size by reducing the numerical bit-width of weights. Common options include 8-bit, 4-bit, and 2-bit. The lower the bit-width, the smaller the size, but the greater the precision loss. Some quantization schemes apply different bit-widths to different layers, retaining higher precision in critical layers to achieve better performance with a minimal size trade-off. When choosing a scheme, focus on three points: whether the target VRAM can accommodate the weights and runtime overhead, whether the post-quantization quality on the target task is acceptable, and whether the quantized artifacts can be reproduced.
2.3 Runtime Environment and Compute Backend
The throughput, compatibility, and driver dependencies of the same model vary significantly across different compute backends. General-purpose graphics compute APIs offer broad coverage and can be used on most graphics cards. Vendor-specific compute platforms deliver better performance on specific hardware but involve stronger ecosystem lock-in. The selection should be based on a comprehensive evaluation of the team’s existing hardware, operational capabilities, and performance goals, rather than just looking at single-item benchmark scores.
3. Capacity Planning: From Weights to Available VRAM
Before deployment, you must calculate the VRAM budget. The total demand consists of four parts:
- Main model weights;
- Visual projection module weights;
- KV cache, which grows linearly with context length;
- Intermediate activations and runtime buffers.
Let’s illustrate with an example. The quantized main model is approximately 108.7GB, and the visual projection module is about 1.13GB, totaling about 109.8GB. With four 32GB accelerator cards, roughly 29.85GB can be allocated per card, totaling about 119.4GB. Subtracting the weights from the total capacity leaves a margin of about 9.6GB. This space must accommodate both the KV cache and activation values, leaving little room.
The size of the KV cache can be estimated using the following formula:
KV Cache Bytes = 2 × Number of Layers × KV Heads × Head Dimension × Context Length × Bytes Per Element
Here, the coefficient 2 indicates that K and V are each stored once. This formula shows that doubling the context length approximately doubles the cache. Long-text scenarios are often where VRAM is exhausted first.
The following script encapsulates this calculation into functions for quick pre-deployment checks:
def kv_cache_gb(layers, kv_heads, head_dim, ctx_len, bytes_per_elem=2):total_bytes = 2 * layers * kv_heads * head_dim * ctx_len * bytes_per_elemreturn total_bytes / 1024**3def check_budget(weight_gb, projector_gb, cards, per_card_gb, kv_gb, act_gb):capacity = cards * per_card_gbneed = weight_gb + projector_gb + kv_gb + act_gbreturn {"total_capacity_gb": round(capacity, 2),"estimated_demand_gb": round(need, 2),"remaining_gb": round(capacity - need, 2),}
By inputting the actual number of layers, KV heads, and context length, the script can directly output the remaining space. If the remaining value is negative, you should first lower the context limit or switch to a lower quantization tier before attempting to start the model.
4. Multi-GPU Parallelism Configuration
When a single card cannot hold the model, it must be split across multiple cards. Common approaches include:
- Inter-layer splitting (pipeline parallelism): placing different layers onto different GPUs.
