Running Full-Size LLMs on a Single GPU: Coordinating VRAM and System Memory
This article explains why running a full-size quantized LLM on a single GPU often falls short of theoretical throughput, and how VRAM capacity, pinned memory limits, context length, and expert-layer residency constrain one another. It covers capacity estimation, differences between desktop and server environments, a pre-launch decision checklist, a phased validation method, and why cloud deployment is a more reliable path for long context and high throughput.
1. The Problem: Why Running a Full-Size Model on One GPU Is Hard
Over the past year, open weights for very large parameter models have become increasingly common. Quantization has reduced model size significantly, but it also raises the bar for coordinating VRAM and system memory. Many developers first ask whether the GPU has enough VRAM. Once they actually run the model, they find the bottleneck is not a single dimension. Instead, four factors constrain each other: VRAM capacity, pinned memory quota, context length, and expert-layer residency strategy.
A typical scenario: a high-end consumer GPU with 32GB of VRAM, paired with 192GB of system memory, attempts to load a quantized weight file of about 140GB. In theory, the combined VRAM and memory far exceed the model size, but actual throughput may be only about half of the theoretical expectation. The reason is not mysterious. Let’s break it down layer by layer.
2. Four Key Constraints
2.1 VRAM Capacity Sets the Ceiling for “Hot Data”
The context cache of the attention mechanism (KV Cache) and the currently active expert layers must stay in VRAM. Otherwise, every generated token requires moving data across PCIe, and latency rises sharply. The smaller the VRAM, the less hot data can be held at the same time.
2.2 Pinned Memory Quota Is an Invisible Ceiling
Under the graphics driver model of some desktop operating systems, the memory that can be registered as pinned has a fixed quota for direct device-side access. This means that even with 192GB of physical memory, the portion available for VRAM expansion may be only about half. This is not a configuration error, but a resource management policy at the operating system level.
2.3 Context Length and Expert-Layer Residency Trade Off Against Each Other
The longer the context, the larger the KV Cache, and the less VRAM remains for expert layers. Conversely, placing more expert layers in VRAM improves speed, but compresses the available context. The two are in a zero-sum relationship.
2.4 The Cost of Reloading Weights Is Seriously Underestimated
In solutions that lack hot-swappable scheduling, any adjustment to context length or the number of expert layers means releasing loaded weights and reloading them from disk. Even with a high-speed SSD on a fast channel, loading weights at the hundred-GB scale can still take more than ten minutes. This directly determines the tuning rhythm: not a second-level loop of “change config, restart, test,” but experiments measured in hours.
3. Capacity Estimation: Do the Math Before You Start
Before any loading action, it is advisable to make a rough budget to avoid repeated trial and error:
Available VRAM = GPU VRAM - runtime and driver overhead (reserve 1~2GB recommended)KV Cache ≈ 2 × layers × hidden dimension × context length × precision bytes × concurrencyVRAM for resident expert layers = Available VRAM - KV CacheWeights that must use memory/shared pool = Total model size - Resident expert layer size
A practical rule of thumb: if the “weights that must use the shared pool” exceed the pinned memory quota, pinned allocation failures and frequent swapping in and out are almost unavoidable, and throughput will be significantly lower than expected.
4. Desktop vs. Server Systems
The original author ran the model on a desktop system through a virtualization layer, where the core problems were the pinned memory quota and device driver limits. In a server environment, these limits are usually relaxed, memory can serve as a more ample VRAM expansion pool, and long context and higher throughput are easier to achieve at the same time.
So the conclusion is straightforward: this kind of “VRAM + large memory” collaborative inference solution is better suited to servers or cloud container platforms than to relying on a desktop graphics environment. If validation must happen in a desktop environment, the goal should be “getting it to run,” not “meeting performance targets.”
5. A Pre-Launch Decision Checklist
Because reloading is costly, be sure to define the task profile before loading:
- Tasks focused on long-document understanding or repository-level code analysis → prioritize long-context mode and accept lower throughput;
- Tasks focused on interactive Q&A or batch extraction → prioritize high-throughput mode and compress context;
- Need both → consider a layered “main agent + sub-agent” design: the main agent uses long context for planning, sub-agents use short context for execution, with roles distinguished through a configuration file;
- Record the context length, number of expert layers, and measured throughput of each experiment to build a reusable parameter table and reduce repeated loading.
6. A Phased Validation Method
- Minimal validation: load with an extremely short context to confirm weight integrity and output correctness;
- Throughput baseline: fix the context, gradually increase resident expert layers, and find the throughput inflection point;
- Context stress test: at the inflection-point configuration, extend the context and observe the throughput decay curve;
- Stability observation: run for an extended period and watch for pinned allocation failures, page thrashing, and VRAM fragmentation.
7. A More Reliable Path in the Cloud
If the goal is to reliably obtain “long context + high throughput,” it is more advisable to move the workload to the cloud: choose an inference instance with larger VRAM, or split weights using multi-GPU tensor parallelism or expert parallelism; use object storage for weight distribution, a container platform for environment consistency, and monitoring and alerting services to track throughput and VRAM levels. General capabilities offered by Baidu AI Cloud for this kind of inference deployment scenario, such as containerized inference services, object storage, and monitoring and alerting, can significantly reduce environment debugging and operations costs, allowing teams to focus on model quality and business integration.
8. Conclusion
The core of running a very large parameter model on a single GPU is not “whether it fits,” but “how to make trade-offs once it fits.” Understanding the constraints among VRAM, pinned memory, context, and expert layers, doing the math first, loading next, and validating in phases is how you truly unlock the potential of limited hardware.
