Run LLMs on Windows 11 with WSL2 and Ollama

Why WSL2 instead of native Windows Ollama

Ollama ships a perfectly good native Windows installer, so WSL2 is not the only way to run a local model on Windows 11. It is the better way once you want more than a chat window. Docker Compose, Open WebUI, Python scripts that call the Ollama API, and any deployment-style workflow all expect Linux, and WSL2 gives you a real Linux kernel inside Windows without dual-booting. GPU inference runs at near-native speed because the GPU, not the operating system layer, is the bottleneck.

This guide walks through the full setup: WSL2 with GPU passthrough, Ollama inside Ubuntu, a first model, and a ChatGPT-style browser interface with Open WebUI. Budget about 30 minutes, most of it waiting on downloads.


Source: Virtualization Howto — installing Ollama inside WSL2.

Prerequisites

  • Windows 11, or Windows 10 version 22H2 or newer.
  • An NVIDIA GPU with driver version 551.61 or newer if you want GPU acceleration. CPU-only works too, but expect roughly 8–15 tokens per second on a 7B model instead of 30 or more on a mid-range GPU.
  • At least 16 GB of system RAM and 20 GB of free disk. Ollama itself needs a minimum of 8 GB of RAM, and models range from a few hundred megabytes to tens of gigabytes.
  • Administrator access on the Windows side for the WSL2 install.

Step 1: Install WSL2

Open PowerShell as Administrator and run:

wsl --install

That installs the default Ubuntu distribution. To pick a specific one, for example Ubuntu 24.04, run wsl --install -d Ubuntu-24.04 instead. Reboot when prompted, then launch Ubuntu from the Start menu and create your Linux username and password.

One setting is worth changing before you go further. WSL2 defaults to half of your system RAM, so a 32 GB machine gives Ubuntu only 16 GB, which is tight for larger models. Create a file called .wslconfig in your Windows user folder (C:\Users\<you>) with:

[wsl2]
memory=24GB
processors=8

Then shut WSL2 down with wsl --shutdown in PowerShell and start Ubuntu again. Note that GPU memory is not limited by this file: your models get the full VRAM, minus a few hundred megabytes reserved by the Windows desktop.

Step 2: Set up GPU passthrough

This is the step most guides overcomplicate. The rule is simple: install the NVIDIA driver on Windows only. Your normal GeForce Game Ready or Studio driver is enough, and the Windows driver is automatically exposed inside WSL2 as a CUDA library. Do not install any NVIDIA Linux driver inside WSL2 — that is the most common way to break the setup.

Inside Ubuntu, verify the GPU is visible:

nvidia-smi

You should see your GPU model, driver version, and CUDA version. If the command is not found, update the Windows NVIDIA driver and restart WSL2. Ollama bundles its own CUDA runtime, so you do not need the CUDA Toolkit for Ollama itself; install it only if you also build llama.cpp or run PyTorch, and then install the toolkit package only, never the driver packages.

Step 3: Install Ollama inside WSL2

Inside Ubuntu, run the official installer:

curl -fsSL https://ollama.com/install.sh | sh

The script detects the GPU through the WSL2 CUDA stub and sets Ollama up as a systemd service. Check it is running with systemctl status ollama and confirm the version:

ollama --version

As of early November 2026 the current stable release is v0.40.14. If you are starting from scratch, our 20-minute Ollama quickstart covers the same workflow on Linux and macOS.

Step 4: Pull a model and chat

Pick a model that fits your VRAM. On an 8–12 GB card, an 8B model in 4-bit quantization is the sweet spot. If you are unsure how much memory a model needs, see our guide on how much VRAM you need to run an LLM locally.

ollama pull qwen3:8b
ollama run qwen3:8b


Source: freeCodeCamp — a first Ollama chat session (gemma3:270m).

The first command downloads about 5 GB; the second starts a chat in your terminal. Type a question, and you are talking to a model that runs entirely on your own machine. To try something smaller first, gemma3:4b is a 3.4 GB download and also handles images.

Step 5: Add a browser chat UI with Open WebUI

The terminal is fine for testing, but most people want a ChatGPT-style interface. Open WebUI runs in Docker and talks to Ollama over HTTP. First install Docker Desktop for Windows and enable its WSL2 integration, or install Docker Engine inside Ubuntu. Then generate a secret key and start the container:

openssl rand -hex 32
docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data -e WEBUI_SECRET_KEY=your-secret-key --name open-webui --restart always ghcr.io/open-webui/open-webui:main

Open http://localhost:3000, create the first account (it becomes the admin), and point Open WebUI at Ollama. The host.docker.internal entry lets the container reach Ollama on port 11434. Our full Open WebUI tutorial walks through the settings, RAG document upload, and multi-user setup in more detail.

Troubleshooting

Ollama fails with a systemd error

Older WSL2 installs may not boot with systemd, and Ollama needs it. Add [boot] systemd=true to /etc/wsl.conf inside Ubuntu, then run wsl --shutdown from PowerShell and relaunch.

nvidia-smi works in Windows but not in WSL2

Update the Windows NVIDIA driver to the latest Game Ready or Studio release and restart WSL2. Never install the Linux driver inside WSL2; the two drivers conflict and the WSL2 one always loses.

Model downloads are extremely slow or stall

Ollama's own FAQ notes that WSL2 networking settings can interfere with downloads. In Windows Device Manager, find your network adapter and disable "Large Send Offload Version 2 (IPv4)" and the IPv6 equivalent, then retry the pull.

The model runs on CPU instead of the GPU

Run ollama ps while a model is loaded: the processor column should say 100% GPU. If it says CPU, check that nvidia-smi sees the GPU inside WSL2 and that the model fits in VRAM; an oversized model silently falls back to CPU offload and crawls.

Open WebUI cannot reach Ollama

Make sure Ollama is listening (try curl http://localhost:11434/api/version inside Ubuntu) and that the container was started with the --add-host=host.docker.internal:host-gateway flag. If you want other machines on your network to reach Ollama, start it with OLLAMA_HOST=0.0.0.0 ollama serve — but only on a network you trust, since that exposes the API without authentication.

What to do next

Once the stack is running, the natural next steps are all Linux-native, which is exactly why WSL2 pays off. Try a vision model such as Qwen3-VL for image questions, wire Ollama into a Python script through its OpenAI-compatible API at http://localhost:11434/v1, or build a local RAG system on top of the same setup. Windows stays your daily driver; the AI work happens in Linux, on the same machine, with the same GPU, and nothing leaves the house.

Comments

Popular posts from this blog

Open-Source AI Weekly: Bonsai, GigaChat 4 Lead

Claude Claims Proof of Riemann Hypothesis After 167 Years

How to Build an AI Agent with LangGraph in 30 Minutes