Running large language models or Stable Diffusion locally on a Windows machine works beautifully once you give Linux direct access to your NVIDIA GPU, and WSL2 with CUDA is the cleanest route to that. The one rule that trips up almost everyone: the GPU driver lives on Windows only, and inside the Linux distro you install the CUDA Toolkit alone. Get that split right and tools like Ollama and llama.cpp run at near-native Linux speed on your existing card.

Quick Answer

Install the NVIDIA driver on Windows (version 536.123 or newer for full WSL2 support), then inside WSL2 install only the CUDA Toolkit using the WSL-specific package that excludes the driver. Never install the cuda or cuda-drivers meta-packages inside Linux, because they pull a Linux GPU driver that overwrites the WSL passthrough stub and breaks everything. You need Windows 11, or Windows 10 21H2 or later.

What WSL2 GPU passthrough actually does

WSL2 runs a real Linux kernel inside a lightweight virtual machine. When the Windows NVIDIA driver is present, it exposes the GPU to that Linux environment through a stubbed libcuda.so, so CUDA calls from inside Linux are handed straight to the Windows driver. You get the GPU's full compute without dual-booting, and your model files, Python environments and tooling all stay in a tidy Linux filesystem.

The practical upside for local AI is large. Inference engines such as Ollama and llama.cpp report 90 to 100 percent of native Linux throughput under WSL2, which means the GPU you bought for gaming doubles as a capable model-serving box.

Step-by-step setup

  1. Update the Windows NVIDIA driver. Install the latest Game Ready or Studio driver for your GPU. This is the only GPU driver in the whole stack. If you are choosing hardware for this, the AI-focused PC builds at Evetech ship with current-generation NVIDIA cards that are ready for CUDA work out of the box.
  2. Install WSL2. Open PowerShell as administrator and run wsl --install, which fetches the WSL2 kernel and Ubuntu by default. Reboot, then set up your Linux username and password.
  3. Confirm GPU visibility. Inside the Ubuntu shell, run nvidia-smi. If it lists your card, the passthrough is live. If it fails, your Windows driver is too old or WSL needs wsl --update.
  4. Install only the CUDA Toolkit. Follow NVIDIA's WSL-Ubuntu instructions and install the cuda-toolkit-12-x package, not the broad cuda package. This installs nvcc, libraries and headers without touching the driver.
  5. Match the CUDA version to your framework. PyTorch and TensorFlow wheels are compiled against a specific CUDA version, so install the toolkit version your framework expects rather than just the newest.

Performance tuning that matters

Two settings make a real difference. First, edit .wslconfig in your Windows user folder to raise the memory allocation, since WSL2 defaults to roughly half your RAM and large models will otherwise be starved. Second, keep all your model weights and project files inside the Linux filesystem (for example under your home directory) rather than on /mnt/c, because the Windows-mounted path is several times slower for the many small reads an inference engine performs.

Once that is in place, pulling a model with Ollama or building llama.cpp with CUDA support gives you GPU-accelerated local inference with no internet round trip and no per-token cost.

Choosing the right hardware

VRAM is the gatekeeper for local models. A card with 8GB runs smaller quantised models comfortably; 12GB to 16GB opens up mid-sized models at usable speed; and 24GB lets you load larger models without aggressive quantisation. System RAM matters too, since offloading layers to CPU when VRAM runs short is far less painful with 32GB or more. The best-selling desktop builds at Evetech are a useful starting point for matching GPU and memory to the model sizes you intend to run.

Frequently Asked Questions

Do I need to install an NVIDIA driver inside WSL2?

No, and you should not. The Windows driver handles the GPU and is exposed to Linux automatically. Installing a Linux driver inside WSL2 overwrites the passthrough stub and breaks GPU access.

Why does my CUDA install break the GPU?

You almost certainly installed the full cuda or cuda-drivers package, which bundles a Linux driver. Reinstall using only the cuda-toolkit package built for WSL-Ubuntu.

How much VRAM do I need for local LLMs?

Small quantised models run on 8GB. For comfortable mid-sized model inference, aim for 12GB to 16GB, and for larger models with less quantisation, 24GB. More VRAM lets you keep the whole model on the GPU.

Can I use Ollama directly on Windows instead of WSL2?

Ollama does run natively on Windows, but WSL2 gives you the fuller Linux tooling ecosystem and is the better base if you also want llama.cpp, custom builds or Linux-only frameworks.

Why are my model files loading slowly?

They are probably stored on /mnt/c. Move them into the native Linux filesystem inside WSL2, where read performance for many small files is dramatically faster.

Building a machine for local AI inference? Compare the GPU and memory options in the Evetech AI PC range and set up a desktop that runs your models locally, privately and at full speed.