Why Your Local LLM Runs on CPU Only: GPU Invocation Principles and Acceleration Practices
This article explains why local LLM inference often falls back to CPU even when a GPU is detected, and how to fix it. It separates device detection, VRAM usage, and actual compute utilization; breaks down five common fallback causes such as layered offloading, unsupported quantization operators, a misconfigured driver stack, oversized context and batch settings, and aging hardware; and presents a systematic troubleshooting workflow covering device visibility, driver versions, minimal-load testing, capacity estimation, log analysis, and controlled experiments. It closes with practical optimization tips and notes cloud elastic inference as a complement when local VRAM is the limit.
1. The Symptom: Seeing a GPU Is Not the Same as Using It
When deploying LLMs locally, a common source of confusion is this: the runtime log clearly shows that a GPU was detected, and VRAM usage is non-zero, yet the GPU utilization in Task Manager stays near 0 for long stretches while the CPU remains fully loaded. Inference is far slower than expected. This is usually not a “broken GPU” but a runtime that has fallen back to the CPU for most of the computation graph.
To understand this, it helps to separate three concepts that are easy to conflate:
- Device detected: The runtime enumerated available accelerators through the underlying compute interface. This only means “available,” not “in use.”
- VRAM occupied: Tensors, caches, or context data exist in VRAM. A small, constant footprint may simply be initialization and resident data.
- Compute in use: The actual matrix multiplications and attention computations run on the accelerator, showing up as utilization that fluctuates sharply during inference.
These three are progressive. Only when the third one holds can you call GPU invocation “successful.”
2. Root Causes: Five Common Reasons for Fallback
2.1 Layered Offloading Due to Insufficient VRAM
The VRAM requirement for LLM inference can be estimated roughly as:
VRAM required ≈ parameters × bytes per parameter + context cache + runtime overhead
Take the 8B and 14B model sizes as examples. With 8-bit quantization, the weights alone take about 8GB and 14GB respectively. Add the context cache and runtime overhead, and older GPUs (typically 4GB to 8GB of VRAM) can hardly hold everything. The runtime then keeps the layers that fit in VRAM and leaves the rest in system memory for the CPU to compute, producing the classic signature of “VRAM occupied but compute not ramped up.”
How to check: watch whether VRAM usage stays fixed during inference while system memory keeps climbing as generation proceeds. If so, layered offloading is almost certainly happening.
2.2 Mismatched Quantization Format and Operator Support
Different quantization schemes rely on different low-level operators, especially matrix multiplication and fused dequantization operators. When the model’s quantization format lacks an efficient implementation on the runtime’s acceleration backend, the affected operators are treated as “unsupported” and fall back to the CPU. In the logs, this typically shows up as clusters of unsupported-operator messages rather than out-of-memory messages.
2.3 Acceleration Backend and Driver Stack Not Properly Enabled
Acceleration depends on three layers being ready at once: runtime, driver, and hardware. Common breakpoints include an outdated driver, a missing acceleration runtime or one that is not active in the environment, devices not correctly passed through inside a container, and environment variables that restrict device visibility to nothing. Any of these can leave the runtime “able to see but unable to use” the device, or push it onto a CPU-only path.
2.3 Context Length and Batch Settings Amplifying VRAM Pressure
The context cache (KV Cache) grows roughly linearly with context length. Push the context very high or run many concurrent requests, and VRAM demand can balloon quickly. Even when the weights themselves fit, cache overflow can trigger fallback. This is a common reason why “even a small model won’t run.”
2.5 Compute and Instruction-Set Bottlenecks on Older Hardware
Even when computation is successfully placed on the GPU, older GPUs have limited VRAM bandwidth and parallel capacity, so the speedup may be modest. In addition, some newer acceleration instruction sets are unavailable on old hardware, which further reduces the real gains. For this reason, “invocation succeeded” and “noticeably faster” should be evaluated separately.
3. A Systematic Troubleshooting Workflow
Verify layer by layer in the following order instead of blindly tuning parameters:
- Confirm device visibility: Query the accelerator device list in the environment and confirm the runtime can actually see the target device, with the expected count and names.
- Confirm driver and runtime versions: Check that the driver and acceleration runtime fall within a supported combination, and upgrade to a stable version if necessary.
- Minimal verification: Run inference once with a tiny model and a very short context, and watch whether accelerator utilization fluctuates noticeably. Normal fluctuation means the pipeline is sound and the problem lies at the capacity or operator level.
- Capacity estimation: Estimate the weight and cache requirements using the formula above, compare them against device VRAM, and decide whether to lower the quantization bit width or shorten the context.
- Locate the issue in logs: Distinguish “out of memory” from “unsupported operator” messages. For the former, adjust capacity; for the latter, switch the quantization format or upgrade the runtime.
- Controlled experiment: Fix the model and prompt, change only whether acceleration is enabled, and record first-token latency and tokens generated per second. Draw conclusions from data, not from perception.
The logic of a sample verification script is as follows (pseudocode that only illustrates the troubleshooting approach):
# 1) Query device visibilityprint(query_accelerator_devices())# 2) Minimal-load verification: short context + small modelresp = chat(model="tiny-model", prompt="hi", options={"num_ctx": 512})# 3) Record metrics: first-token latency and throughputprint(measure_first_token_latency(resp), measure_tokens_per_second(resp))
4. Optimization Practices: Actually Putting the Compute to Work
- Size the model to your VRAM: At the 8GB level, prioritize the 7B to 8B range with a lower bit-width quantization; consider the 14B range only above 12GB.
- Balance quantization bit width and quality: Lower bit widths save VRAM but increase precision loss. Run a small comparison evaluation on your target task before settling on a setting.
- Control context and concurrency: Set context length to actual needs and avoid maxing it out by default; concurrent requests multiply cache overhead.
- Keep drivers and runtime updated: Acceleration support depends heavily on version combinations. Record the current working state before upgrading so you can roll back.
- Let metrics drive decisions: Always base optimization on three metrics: first-token latency, tokens generated per second, and peak VRAM usage.
- Cloud elasticity as a complement: When local VRAM is constrained, you can move large-model inference to a cloud container platform or a function-based inference service that scales elastically with call volume, and use object storage to host model files plus logging and monitoring services for observability. In these scenarios, Baidu AI Cloud typically offers a combination of general capabilities such as a container platform, object storage, and monitoring and alerting, making it easier to extend a local prototype into an online service smoothly.
5. Conclusion
“A GPU detected in the log, VRAM occupied” only proves the acceleration pipeline is available. What really determines inference speed is whether the model fits in VRAM, whether the operators are supported, whether the driver stack is ready, and whether the context is under control. Troubleshoot in the order of visibility, versions, minimal verification, capacity estimation, log analysis, and controlled experiments, and the vast majority of “CPU-only” problems can be clearly located and resolved. For scenarios beyond the local hardware limit, cloud elastic inference is a reasonable complement, forming an engineering practice that combines local verification with cloud scaling.
