People on /r/localllama are saying they are getting over 100t/s on qwen3 with llama.cpp and on ollama only 15t/s. I have a 8700xt but only get 15t/s on both, am I missing a parameter?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Okay, let's break down why you might be seeing significantly lower performance than expected with your RX 7800 XT on both llama.cpp and Ollama, especially compared to reports of >100 t/s.
15 t/s on a powerful GPU like the 7800 XT strongly suggests the GPU is not being fully utilized or not being used correctly for inference. Here's a checklist focusing on potential missing parameters and configuration issues:
Key Culprit (Especially for llama.cpp): GPU Offloading Parameter
llama.cpp: -ngl (Number of GPU Layers): This is the most critical parameter you might be missing or setting incorrectly. It tells llama.cpp how many layers of the model to offload to the GPU's VRAM.
If -ngl is 0 or not specified (defaults to 0): The entire model runs on the CPU, which would explain the very low 15 t/s. Your CPU might be decent, but it won't hit high token rates for LLMs alone.
If -ngl is set too low: Only a small part of the model runs on the GPU, leaving the CPU bottlenecked.
How to set it: For a 7B model like Qwen2-7B on a 16GB card like the 7800 XT, you should be able to offload all layers. Try setting it very high, like -ngl 999 or -ngl 100 (llama.cpp will automatically figure out the maximum possible for the specific model and clamp it). A typical 7B model has around 32-40 layers, so setting -ngl 35 or -ngl 40 would also likely offload everything.
Example Command:
bash
./main -m ./models/qwen2-7b-instruct-q4_K_M.gguf -p "Translate the following English text to French: 'Hello, world!'" -n 128 -ngl 35
(Adjust model path/name, prompt -p, context size -n, and other parameters as needed. Start with a high -ngl value).
General Checks (Apply to Both llama.cpp & Ollama)
GPU Drivers & Compute Backend (ROCm / Adrenalin):
Operating System? This is crucial.
Linux: You absolutely need the correct AMD ROCm drivers installed for GPU compute. Verify your installation:
Run rocminfo in the terminal. Does it show your GPU?
Run rocm-smi. Does it show your GPU, VRAM usage, temperature?
If these commands fail or don't list your GPU, your ROCm setup is incomplete or incorrect. Ollama and llama.cpp (built with ROCm support) depend on this. Follow AMD's official ROCm installation guide for your distribution carefully.
Windows: Support for AMD GPUs often relies on the standard AMD Adrenalin drivers providing DirectML or potentially Vulkan compute capabilities.
Ensure you have the latest recommended (not necessarily optional/beta) Adrenalin drivers installed from AMD's website.
llama.cpp might need specific compile flags (-DLLAMA_VULKAN=ON or potentially DirectML flags if the backend supports it).
Ollama should automatically use DirectML if drivers are present and correct.
Correct Build/Installation:
llama.cpp: Did you compile llama.cpp with GPU support enabled?
Linux (ROCm): You typically need to set LLAMA_HIPBLAS=1 during the make or cmake process. Example: make LLAMA_HIPBLAS=1. Check the compilation output – it must mention detecting ROCm/HIP and building GPU kernels. If you just ran make without flags, you almost certainly got a CPU-only build. Recompile with the correct flag.
Windows: You might need flags like LLAMA_VULKAN=1 or others depending on the backend you want to target (Vulkan is often preferred for cross-vendor compatibility if available). Check the llama.cpp build instructions for Windows AMD GPUs.
Ollama: Ollama is pre-built and should detect and use the GPU automatically if the underlying drivers (ROCm on Linux, DirectML via Adrenalin on Windows) are correctly installed before Ollama is run or started.
Sometimes, stopping the Ollama service/app, ensuring drivers are correct, and then restarting Ollama helps.
Check Ollama's logs for errors related to GPU detection. On Linux with systemd: journalctl -u ollama. Look for lines mentioning ROCm, HIP, or GPU detection successes/failures. On Windows, check the application's log files (location might vary).
Model Quantization: While reports of 100 t/s might use faster, lower-precision quants (e.g., Q3_K_S, Q4_K_M), even higher-quality quants (Q5_K_M, Q6_K, Q8_0) on a 7800 XT should be much faster than 15 t/s if the GPU is engaged. Ensure you're using standard GGUF format models. The quant affects the speed ceiling, but 15 t/s points to a more fundamental issue (likely CPU usage).
VRAM Usage: Monitor your GPU's VRAM usage during inference.
A 7B model (like a Q4_K_M, ~4-5GB) plus context should fit comfortably within your 16GB VRAM. If VRAM usage hits 100% and your system RAM usage spikes simultaneously, you might be running out of VRAM (e.g., due to a very large context window -c in llama.cpp) and swapping, which kills performance. This is less likely for standard usage with a 7B/16GB combo but worth checking.
System Monitoring: While running inference, monitor:
GPU Utilization: (Task Manager / rocm-smi). Is it near 100% or very low? Low utilization confirms the GPU isn't the bottleneck (and likely isn't being used much).
GPU Power Draw: (rocm-smi / GPU Tweak tools). High power draw indicates the GPU is working.
CPU Utilization: Is one or more CPU cores pegged at 100%? This confirms a CPU bottleneck, likely because the GPU isn't being used (or not enough layers are offloaded).
Troubleshooting Steps:
Verify Drivers: Confirm ROCm (Linux) or Adrenalin (Windows) drivers are correctly installed and detecting the GPU for compute.
Recompile llama.cpp (if applicable): Ensure you use the correct GPU flag (LLAMA_HIPBLAS=1 for Linux/ROCm).
Use -ngl in llama.cpp: Start with a high value like -ngl 999. Check the llama.cpp startup output – it should report how many layers it actually offloaded to the GPU.
Check Ollama Logs: Look for GPU detection messages or errors. Try reinstalling Ollama after confirming drivers are working.
Monitor System Resources: Use rocm-smi/Task Manager during inference to see if the GPU or CPU is the bottleneck.
By systematically checking these points, especially the -ngl parameter for llama.cpp and the driver/build configuration for both, you should be able to identify why your 7800 XT isn't delivering the expected performance.