Deploying Multimodal LLMs on Alternative GPUs: A Practical Guide with Quad-GPU Testing
This article explores the deployment of an open-source multimodal large language model on a workstation equipped with four 32GB alternative GPUs. It covers essential steps including VRAM estimation, framework branch selection, dynamic quantization, multimodal projection (mmproj) configuration, and multi-GPU startup commands. Functional and performance test results are also shared to provide practical insights for developers facing hardware constraints.
1. Introduction: Alternative GPUs Can Run Multimodal LLMs
Multimodal large language models can process text and images simultaneously, and some also support video. Because of their large number of parameters and high VRAM requirements, many developers are limited to high-end GPUs from specific vendors. In reality, as long as VRAM is properly estimated, the right quantization scheme is chosen, the visual projection module is correctly configured, and the model is split across multiple cards, workstation-grade GPUs can successfully handle text and image inference.
This article uses an open-source multimodal model as an example to document its deployment on four 32GB workstation GPUs. It covers VRAM estimation, framework branch selection, quantization schemes, mmproj configuration, multi-GPU startup commands, and test results. All data in this article is recorded on a single machine and may not represent all hardware environments.
2. VRAM Estimation Before Deployment
VRAM requirements can be estimated using the following formula:
VRAM requirement ≈ Quantized weights + Visual projection weights + KV cache + Compute buffer
For this example, the original FP16 weights are approximately 320GB. The quantized main model is about 108.7GB, and the visual projection module (mmproj, FP16) is about 1.13GB, totaling approximately 109.8GB.
The four cards have a combined physical VRAM of 128GB, with about 119GB actually available. After deducting the weights, about 9GB remains, which accounts for 7.6% of the available VRAM. This margin is below the commonly recommended 10% reserve, meaning the context length must be strictly controlled.
The KV cache size depends on the context length and is calculated as follows:
Bytes per token for KV cache = 2 × Number of layers × Number of KV heads × Head dimension × Bytes per element
Let’s demonstrate with hypothetical architecture parameters: 60 layers, 8 KV heads, head dimension of 128, and FP16 KV cache (2 bytes per element).
Bytes per token = 2 × 60 × 8 × 128 × 2 = 245,760 bytes (~0.25MB).
- 10,000 token context: ~2.5GB
- 32,000 token context: ~8GB
10,000 tokens can fit into the remaining 9GB margin, while 32,000 tokens will exceed it. Substitute the actual number of layers and KV heads from the model configuration file instead of using the numbers above directly.
The compute buffer size depends on the batch size and context length, and cannot be precisely determined by a simple formula. After deployment, it is recommended to use nvidia-smi or rocm-smi to observe the actual usage of each card to determine the available limit.
3. Framework Branch and Quantization Scheme
3.1 Verify the Framework Branch First
Mainstream inference frameworks sometimes lag in their support for multimodal models. This example uses a community-maintained branch that has enabled text and image inference, though video input is not yet integrated.
When selecting a branch, it is recommended to verify the following in the repository:
- Whether a branch or commit specifically for this model exists;
- Whether the unmerged commit notes state the support scope and known issues;
- Record the specific commit hash for future reproduction.
Simply looking at the branch name is not enough to judge its usability.
3.2 Actual Bitrate of Dynamic Quantization
This example uses dynamic quantization, with a “2-bit” identifier in the filename. This type of dynamic quantization mixes different bit widths based on tensor importance, retaining higher precision for critical tensors, so the average bitrate is higher than the nominal level.
Let’s verify with numbers:
- Compression ratio = 320GB ÷ 108.7GB ≈ 2.94x
- Average bitrate ≈ 16 × (108.7 ÷ 320) ≈ 5.4 bit/weight
This means the model’s average precision is about 5.4 bits, not 2 bits. This dictates the expectation for precision loss.
When selecting a quantization scheme, pay attention to the following:
- Confirm whether the quantization covers the visual projection layer. In this example, mmproj remains FP16 and is not quantized.
- Check how the output and embedding layers are handled, as they have a significant impact on output quality.
- Use a fixed set of validation samples to compare outputs before and after quantization. Samples should include Q&A, long text, and image tasks.
The table below estimates the main model size by average bitrate for rough comparison only. Actual size depends on the quantization tool’s output.
| Average Bitrate | Estimated Main Model Size | Relative to This Example |
|---|---|---|
| 5.4 bit (This example) | ~108.7GB | Baseline |
| ~4 bit | ~80GB | Reduced by ~26% |
| ~3 bit | ~60GB | Reduced by ~45% |
A smaller size leaves more VRAM for context, but increases precision loss. The lower the level, the more necessary it is to confirm usability with validation samples.
4. Multimodal Projection Module (mmproj)
Multimodal models typically consist of two parts:
- Main model (GGUF format): Responsible for language understanding, reasoning, and text generation.
- Multimodal projection module (mmproj): Contains the visual encoder and projection layer, encoding images into visual embeddings and mapping them to the main model’s semantic space. The file used here is
mmproj-F16.gguf.
During inference, the image first passes through mmproj to generate a sequence of visual embeddings. These embeddings are inserted into the input text sequence and sent to the main model together with the text. Without mmproj, the model cannot accept image inputs.
The mmproj must match the main model version. If you encounter “unrecognized image” errors or loading failures, troubleshoot in the following order:
- Check the version numbers provided on the model release page to ensure the main model and mmproj are from the same release.
- Compare the hashes of the two files to ensure they match the checksums provided on the release page.
- Ask a question about an image with known content, such as counting objects in the image, and manually verify the answer. If the answer clearly contradicts the image, the two files likely do not match.
- Check the startup logs for mmproj-related output to confirm the path is correct and the file has been loaded.
5. Environment Preparation and Deployment Steps
5.1 Compile the Inference Framework
git clone <repository-url>cd llama.cppgit checkout <confirmed-branch-or-commit>cmake -B build -DGGML_HIP=ONcmake --build build --config Release -j $(nproc)
Backend options must match the GPU vendor. NVIDIA GPUs use -DGGML_CUDA=ON, AMD GPUs use -DGGML_HIP=ON (requires ROCm to be installed), and cross-vendor scenarios can try -DGGML_VULKAN=ON. After compilation, it is recommended to record the driver, toolchain, and compiler versions for reproducibility.
After compiling, run ./build/bin/llama-cli --help to confirm the executable exists and check for the -sm parameter. In newer versions of llama.cpp, the multimodal CLI tool is llama-mtmd-cli; rely on the --help output for exact parameters.
5.2 Prepare Weights
Download original weights from the model’s official repository or public sources like HuggingFace. Use the framework’s built-in quantization tool (such as llama-quantize) to generate the main model in GGUF format, and save mmproj-F16.gguf separately. After downloading, verify the file hashes.
5.3 Multi-GPU Startup Command
./build/bin/llama-mtmd-cli \-m ./model/quant-dynamic.gguf \--mmproj ./model/mmproj-F16.gguf \--image ./test/sample.jpg \-p "Describe the objects, colors, and spatial relationships in this image." \-ngl 999 -sm layer -mg 0 -ts 1,1,1,1 -c 8192
Parameter descriptions:
-ngl 999: Offloads all layers to the GPU as much as possible. A value exceeding the actual number of layers equals a full offload.-sm layer: Splits the model across multiple cards by layer. Valid values for-smarenone,layer, androw. The commonly seen--split-mode pipelinedoes not exist in llama.cpp; use-sm layerinstead.-mg 0: Specifies the main GPU, used to store partial intermediate results.-ts 1,1,1,1: Distributes the load proportionally across cards, which has the same effect as0.25,0.25,0.25,0.25.-c 8192: Context length. This is one of the most VRAM-sensitive parameters.
For pure text inference, you can switch to llama-cli and remove --mmproj and --image.
5.4 VRAM Monitoring and Tuning
Use nvidia-smi or rocm-smi during runtime to observe the VRAM usage of each card. If OOM (Out of Memory) occurs, adjust in the following order, changing only one item at a time:
- Lower the
-cvalue first, for example from 16384 to 8192. This has the most direct impact on VRAM. - Check if the usage across cards is balanced. If one card is noticeably fuller, adjust the
-tsratio. - If still insufficient, switch to a smaller quantization level, such as an average ~3-bit version.
Do not use Q3 to replace smaller levels in this example. The bitrate of Q3 is higher than the dynamic quantization level used here, resulting in a larger file.
After each adjustment, retest with the same fixed prompts and images to ensure the output is still normal. Long text tasks can be input in segments: summarize paragraph by paragraph first, then merge the results.
6. Functional Testing and Results Analysis
6.1 Text Capabilities
- Short Q&A: Input “Explain what quantum entanglement is.” The response is coherent and close to the results from the official API. This is a manual spot check and does not represent a comprehensive evaluation.
- Long text retrieval: Input a technical document of about 10,000 tokens and ask the model to extract key information. The model can locate and recite relevant paragraphs, with a generation speed of about 12 tokens/s and VRAM usage near the limit.
It is important to distinguish between two metrics here. 12 tokens/s refers to the speed during the generation phase, while 48 seconds refers to the end-to-end latency, including input prefill and output generation. The two are not interchangeable.
6.2 Image Understanding
Input a 1024×1024 photo of multiple objects. The model correctly describes the objects, colors, and spatial relationships, with a clear output structure and no visual embedding errors. Video input was not tested this time.
6.3 Performance Records
| Task Type | End-to-End Latency (Single Record) | Peak Combined VRAM (Single Record) |
|---|---|---|
| Short text (~200 token input) | ~2.3 seconds | ~112GB |
| Long text (~10k token input) | ~48 seconds | ~118GB |
| Single image (1024×1024) | ~4.8 seconds | ~115GB |
Each of the above values is a single record; no averages were taken, and warmup, output length, and batch size were not recorded. Please record these conditions simultaneously when reproducing.
The long text task peaked at 118GB, approaching the available limit of 119GB, which is consistent with the estimation in Section 2. Video input, batch inference, and multi-request concurrency were not covered in this test.
7. Summary and Outlook
The practice in this example can be summarized as follows:
- Estimate before deploying. Weights plus mmproj already occupy about 110GB, leaving about 9GB; the context length needs to be controlled.
- Base the framework branch on actual commits and record the commit hash.
- The nominal bitrate of a quantization level does not equal the average bitrate. Reverse-calculate by size before judging precision loss.
- The mmproj must match the main model and be validated with an image of known content.
- For this example, long context is the primary bottleneck.
Whether video input, batch inference, and more efficient attention mechanisms can be utilized depends on when the framework branch is merged into the mainline. Before deploying, please check the update logs of the corresponding repository; do not presume the support scope.
