Ollama Local Model Setup & Performance Troubleshooting
A targeted diagnostic prompt to pinpoint and resolve slow inference, CUDA/ROCm acceleration issues, Modelfile parameters, and context window limits in Ollama.
Customize & Generate Your Prompt
Adjust the variables below. Your customized prompt updates live in real-time ready to copy with zero setup.
Please help me diagnose and fix an issue with my local Ollama model deployment. ### Environment & Hardware Setup - **Model Name & Quantization**: llama3.3:70b-instruct-q4_K_M - **Hardware & VRAM**: NVIDIA RTX 4080 (16GB VRAM) + 64GB DDR5 System RAM - **Operating System**: Windows 11 (Ollama Windows Native) - **Observed Problem or Error Message**: ```text Inference is extremely slow (around 1.5 tokens per second). When I ask questions with long code files, the model stops responding or crashes with "error: out of memory (CUDA error: out of memory)". ``` ### Diagnostic Requirements 1. **Root-Cause Analysis**: - Explain why this error or performance degradation occurred on this specific hardware combination. - Confirm whether the model fits entirely into VRAM or is partially offloading layers to system RAM. 2. **Terminal Remediation Steps**: - Provide the exact shell commands (PowerShell, Bash, or Zsh) to verify GPU detection, check Ollama server status, and restart the daemon. 3. **Optimized Modelfile Configuration**: - Provide a customized `Modelfile` with optimal parameters (`num_ctx`, `num_gpu`, `num_thread`, `temperature`) tuned for this hardware. 4. **Benchmarking & Validation**: - Provide a quick `curl` command to test API response latency and calculate tokens-per-second output.
How to Use This Prompt Effectively
- 1Enter your exact model name and your hardware specifications (GPU model and VRAM).
- 2Paste your error output or describe the slow token generation rate.
- 3Follow the step-by-step diagnostic commands to configure GPU offloading and optimize your Modelfile.
Representative AI Output
Sample output produced when using frontier AI models with the default parameters:
### Root Cause A 70B model quantized at Q4_K_M requires approximately 43GB of memory. On a 16GB RTX 4080, only ~20-25 of the 80 layers fit into VRAM. The remaining 55+ layers are evaluated in system RAM over the PCIe bus, resulting in 1-2 tokens/sec. When context size (`num_ctx`) expands, the KV cache pushes the GPU past its 16GB threshold, triggering CUDA OOM. ### Recommended Fix: Switch to Qwen2.5-Coder:32b or 14b For full GPU acceleration, use a model that fits completely in your 16GB VRAM: ```bash ollama run qwen2.5-coder:14b ``` ### Custom Modelfile with Safe Context ```dockerfile FROM llama3.3:70b-instruct-q4_K_M PARAMETER num_ctx 4096 PARAMETER num_gpu 22 PARAMETER temperature 0.6 ```
Pro Optimization & Edge-Case Tips
- Check how many layers fit into VRAM in real-time by running `ollama ps` while a query is processing.
- Always leave at least 1.5GB to 2GB of VRAM headroom for Windows OS desktop compositing and browser hardware acceleration.
- If you need long context (32K+), look into flash attention and Q4_0 KV cache compression flags.
Related Tools on SPAUL Hub
More in Local AI & Hardware
View CategoryGPU VRAM & Local LLM Quantization Planner Prompt
Plan your local AI hardware footprint with precision. Calculate weights, KV cache consumption across context sizes, and determine the exact quantization level required for full GPU offload.
Hugging Face Model Benchmarking & Evaluation Plan Prompt
Create an empirical evaluation pipeline to compare candidate models from Hugging Face. Measure Time to First Token (TTFT), token throughput, reasoning accuracy, and JSON schema adherence.