Skip to content

RTX 4060 Ollama Not Using GPU: A Full num_gpu Layer Troubleshooting Flow

Scope: Ollama on Windows or WSL2 with an RTX 4060 (8 GB VRAM); ollama run answers but is painfully slow, ollama ps shows 100% CPU, and the log says offloaded 0/N layers to GPU. Five steps - driver, detection, layer count, VRAM, backend - with copyable commands.

Short answer: in most "4060 not using GPU" cases the card is fine and Ollama supports it - the hardware page lists the RTX 4060 under GeForce RTX 40xx, compute capability 8.9. The likely root causes, in order, are an outdated driver, failed GPU discovery, weights plus context exceeding the 8 GB budget, and broken passthrough in WSL2 or Docker. The Ollama documentation and GitHub repository are the sources every command and parameter here was checked against. Where this text says "verify against your environment", the value varies with card revision, driver, and Ollama version.

1. Quantify the symptom: let ollama ps and the log speak

First turn "GPU not used" into a readable number. Run this while the model loads or right after inference:

ollama ps

Per the official FAQ, the PROCESSOR column shows 100% GPU when the whole model is in VRAM, 100% CPU when it is all in system memory, and a mixed value such as 48%/52% CPU/GPU when layers are split. Anything but 100% GPU deserves a closer look. The table reflects currently loaded models; after the idle timeout it may be empty, so send a short prompt to reload the model.

The second piece of evidence is the service log. On Windows, press Win+R and type %LOCALAPPDATA%\Ollama (latest log server.log, older ones server-#.log); on Linux use journalctl -u ollama --no-pager --follow --pager-end; in a container use docker logs <container-name>. Look for this line:

msg="offloaded 0/35 layers to GPU"

The denominator is the model's total layer count; the numerator is how many layers reached the GPU. A numerator of 0 matches 100% CPU in ollama ps. This format comes from ml/backend/ggml/ggml.go (offloaded %d/%d layers to GPU); older llama.cpp builds said load_tensors: offloaded X/Y layers to GPU, so wording varies by version. Archive this line plus ollama ps as your baseline and compare after each step.

2. Layer one: driver version and compute capability

The official hardware page sets the NVIDIA bar at compute capability 5.0+ with driver 550+ (570+ for capability 5.0-6.2 cards). The RTX 4060 is 8.9, so the driver is the likely blocker; the Windows page requires 551.61+ for native installs. An old driver may fail GPU discovery at startup and silently fall back to CPU.

nvidia-smi

Read the driver version in the top-right corner; if it is below the official threshold, upgrade, reboot, restart Ollama, and re-run ollama ps plus the log check. Laptop, OEM, and corporate images often ship drivers far behind the vendor's site, so trust nvidia-smi over Device Manager. On Linux, if Ollama drops to CPU after suspend/resume, the hardware page documents a known driver bug worked around by reloading the user-space module:

sudo rmmod nvidia_uvm && sudo modprobe nvidia_uvm

Then restart the Ollama service and verify again. This problem has a distinct "appears after running for a while" signature and is different from a CPU-only start caused by an old driver; treat them separately.

3. Layer two: confirm Ollama actually sees the card

A sufficient driver version does not mean Ollama can use the GPU. nvidia-smi only proves the OS sees the card; check Ollama's own discovery phase too. The official troubleshooting guide states that Ollama inventories GPUs at startup to judge compatibility and VRAM; when discovery fails it falls back to CPU, and the log may show error codes such as 3 (not initialized), 46 (device unavailable), 100 (no device), or 999 (unknown). When you see those codes, suspect the runtime before the model.

If Ollama runs in a container, first validate passthrough on its own:

docker run --rm --gpus all ubuntu nvidia-smi

This is the official passthrough smoke test (docker run --gpus all ubuntu nvidia-smi) with --rm added so the throwaway container cleans itself up; the --gpus all flag is the part that must match.

Only when this lists the RTX 4060 inside the container is the runtime healthy. You need nvidia-container-toolkit and a nvidia Docker runtime. On Linux also try sudo nvidia-modprobe -u, reload with sudo rmmod nvidia_uvm then sudo modprobe nvidia_uvm, and reboot. If discovery still fails, set CUDA_ERROR_LEVEL=50 and inspect sudo dmesg | grep -i nvrm and grep -i nvidia; include these when filing an issue.

An easily missed switch is CUDA_VISIBLE_DEVICES: the hardware page says an invalid ID (e.g. -1) forces CPU-only use. A leftover -1 hides the 4060 and mimics a driver fault. Check user environment variables on Windows, or systemctl edit ollama.service [Service] on Linux; restart after changes. On multi-GPU hosts use nvidia-smi -L for UUIDs since numeric ordering varies.

4. Layer three: num_gpu and what "layers" really mean

Once the card is visible but the offloaded numerator is still 0, look at the layer parameter. In Ollama's api/types.go, the Runner struct has a field NumGPU with JSON tag num_gpu; DefaultOptions() sets it to -1 (a source comment says -1 means set dynamically). So the default is not "offload zero layers" but "let the scheduler compute the count from model size and VRAM". That explains a 0/N log: the model would not fit, or discovery found no device.

Version caveat: the current public Modelfile table and API ModelOptions schema do not list num_gpu, yet the field exists in source and is deserialized from JSON; older material calls it gpu_layers. Name, passing method, and effect all vary by version - verify against your installed version. Two ways in: inside ollama run use the slash command; over the API put num_gpu in the options object. Then unload/reload (e.g. ollama stop) and compare the offloaded numerator.

A practical rule for an 8 GB card: the denominator in offloaded is the model's total layer count (a 35-layer denominator has appeared in real logs). Treat full offload and full CPU residency as the two extremes; a partial offload is possible but usually causes a steep slowdown because intermediate results cross the PCIe bus on every token. The goal is not "offload a few layers" but "either nearly all layers, or switch to a smaller model". If raising the count exhausts VRAM, causes errors, or crashes Ollama, the bottleneck is capacity, not the parameter - go to the next section.

5. Layer four: the 8 GB VRAM boundary and model choice

The RTX 4060 has 8 GB of VRAM - a hard ceiling tuning cannot overcome. Per the official FAQ, Ollama checks required versus available VRAM at load time: a model that fits on one GPU loads there (best performance); otherwise it spreads across GPUs, and a single-GPU machine has nowhere to spread, so it degrades toward CPU. Budget for the KV cache and runtime overhead as well as weights; both grow with context and concurrency. The FAQ's example of a 2K context times four parallel requests yielding 8K makes the point: the budget is "weights + KV cache + overhead", not file size.

Hence: prefer smaller models and lower quantization tiers so weights sit clearly below VRAM with context headroom. See LLM Quantization in Practice for how q4/q8 tiers affect size and the Ollama Deployment Handbook for a VRAM quick-reference table - several 7B-class entries sit right at 8 GB, meaning "it runs, with little headroom" on a 4060; a larger context or second resident model pushes it back to CPU. Then ollama ps shows a mixed ratio and the offloaded numerator drops below the denominator. Recovery order: return num_ctx to default or lower, drop parallel requests, ensure no second model is resident, and if needed switch to a smaller model or lower quantization tier.

6. Layer five: Windows native, WSL2, and Docker backend differences

The same card behaves differently by where Ollama runs - the last piece of the "I upgraded the driver and it still uses CPU" puzzle.

Native Windows: Ollama is a native Windows app with NVIDIA GPU support, requiring Windows 10 22H2+ and driver 551.61+. Check nvidia-smi and ollama ps, then %LOCALAPPDATA%\Ollama\server.log. If a GPU library is loaded but the layer count stays 0, return to section 4 and check VRAM.

WSL2: run nvidia-smi in both Windows PowerShell and the WSL2 distro; the 4060 must appear in both. If the host is fine but WSL2 is not, it is a passthrough problem - upgrade the host driver first. The FAQ also notes a Windows 10 WSL2 networking slowdown; disable Large Send Offload on the virtual adapter if needed.

Docker on WSL2 or Linux: the section 3 container check must pass. The FAQ says Docker GPU acceleration needs nvidia-container-toolkit and works on Linux or Windows with WSL2 only. The guide also records a container that starts on GPU then switches to CPU later; fix by adding "exec-opts": ["native.cgroupdriver=cgroupfs"] to /etc/docker/daemon.json and restarting Docker - a distinct "fine at startup, then discovery failures" signature.

The decision split: 100% CPU with a normal offloaded denominator and no error codes points to the VRAM budget; error codes or container nvidia-smi failure point to discovery/passthrough; no offloaded line means upgrade Ollama and retest (log wording evolves - verify against your environment). With the five steps, that is a complete decision tree. Inference Engine Selection helps judge another serving stack.

7. Three field cases: one card, three root causes

Three representative incidents, with business details removed and reusable reasoning only:

Case 1 - outdated driver. A 4060 desktop showed 100% CPU right after install with no error codes; nvidia-smi showed a driver below 550. After upgrading past the threshold and rebooting, the log read offloaded 33/35 layers to GPU and ollama ps flipped to 100% GPU. Easy to fix, easy to overlook - users assume a card that lights up has a good driver.

Case 2 - model just over 8 GB. Good driver, working passthrough, but offloaded read 22/35 and ollama ps showed ~60%/40% GPU/CPU, nearly an order of magnitude slower. A 7B-class quantized model with generous context exceeded 8 GB once KV cache was counted. Reclaiming context and lowering the quantization tier restored near-full offload. Lesson: balance the VRAM budget before adding layers.

Case 3 - a stale environment variable. WSL2 Ollama passed both nvidia-smi checks and the container test, yet the log stayed at 0/N. The culprit was a user-level CUDA_VISIBLE_DEVICES=-1 left over from a CPU-only test; removing it fixed everything. Keep a checklist of backend-changing variables - CUDA_VISIBLE_DEVICES, OLLAMA_LLM_LIBRARY, OLLAMA_VULKAN - and review them every pass. The guide shows OLLAMA_LLM_LIBRARY="cpu_avx2" ollama serve as an override that bypasses autodetection.

8. Acceptance checklist before calling it done

  • nvidia-smi driver meets the official bar (550+; 551.61+ on native Windows), verified against your environment
  • ollama ps PROCESSOR reads 100% GPU or a high GPU share, not 100% CPU
  • offloaded N/M layers to GPU numerator is near the denominator; no discovery failures or codes 3/46/100/999
  • Container path passed docker run --rm --gpus all ubuntu nvidia-smi, with nvidia-container-toolkit installed
  • WSL2: nvidia-smi lists the 4060 in both Windows and the distro
  • No leftover CUDA_VISIBLE_DEVICES=-1
  • Weights plus KV cache leave headroom in 8 GB; no parallel requests or second resident model
  • Ollama and driver versions recorded for later comparison

Automating this is straightforward - combine nvidia-smi, ollama ps, and a log grep into one diagnostic dump - but walk the five steps manually once first so the script has a baseline.