How to Set Up WSL2 with GPU Acceleration on Windows 11 (NVIDIA, AMD and Intel)

A complete step-by-step guide to running GPU-accelerated workloads inside WSL2, covering NVIDIA CUDA, AMD ROCm, and Intel oneAPI.


Introduction

Windows Subsystem for Linux 2 (WSL2) has evolved far beyond a simple compatibility layer. With GPU passthrough support built into Windows 11, you can now run machine learning models, video encoding pipelines, and AI inference workloads directly inside a Linux environment without dual-booting or sacrificing your Windows desktop.

This guide walks you through the full setup process, from enabling WSL2 to validating GPU acceleration inside your Linux distro. Whether you are running an NVIDIA RTX card, an AMD Radeon GPU, or an Intel Arc, there is a path for you here.


Prerequisites

Before you begin, make sure you have:

  • Windows 11 (Build 22000 or later, check with winver)
  • A compatible GPU: NVIDIA (Kepler or newer), AMD (RDNA 1 or newer), or Intel (Xe or newer)
  • Administrator access on your machine
  • An internet connection for downloading drivers and packages

Tip: Press Win + R, type winver, and hit Enter to confirm your Windows build number.


Part 1: Enable WSL2

Step 1: Enable WSL and Virtual Machine Platform

Open PowerShell as Administrator and run:

wsl --install

This single command enables the required Windows features, installs the WSL2 kernel, and installs Ubuntu by default. Restart your machine when prompted.

If you already have WSL1 installed, upgrade to WSL2:

wsl --set-default-version 2
wsl --list --verbose

The --verbose flag confirms the version column shows 2 for your distro.

Step 2: Install or Verify Your Linux Distro

After reboot, Ubuntu launches automatically for first-time setup. Set your username and password when prompted.

To install a different distro:

wsl --list --online
wsl --install -d Debian

Step 3: Update Your Linux Environment

Inside your WSL2 terminal:

sudo apt update && sudo apt upgrade -y

Part 2: Install the GPU Driver on Windows

Critical: GPU drivers for WSL2 are installed on the Windows side only. Do NOT install native Linux GPU drivers inside WSL2. Doing so will break the GPU passthrough.

NVIDIA GPUs

  1. Download the latest Game Ready or Studio Driver from the NVIDIA website
  2. Install it normally on Windows 11
  3. The driver automatically includes the CUDA on WSL2 components (driver version 470 and above)

Verify inside WSL2 after driver installation:

nvidia-smi

You should see your GPU listed with the driver version and CUDA version.

AMD GPUs

  1. Download the latest Adrenalin Edition driver from the AMD support page
  2. Install it on Windows 11. ROCm support in WSL2 is included in drivers from 2022 onward
  3. Inside WSL2, install ROCm:
wget https://repo.radeon.com/amdgpu-install/7.2.1/ubuntu/noble/amdgpu-install_7.2.1.70201-1_all.deb
sudo apt install ./amdgpu-install_7.2.1.70201-1_all.deb
sudo apt update
sudo apt install python3-setuptools python3-wheel
sudo usermod -a -G render,video $LOGNAME # Add the current user to the render and video groups
sudo apt install rocm

Verify:

rocminfo | grep "Agent 2" -A 5

Intel GPUs

  1. Install the latest Intel Arc and Iris Xe Graphics driver from the Intel website
  2. Inside WSL2, install the Intel oneAPI Base Toolkit:
wget -O- https://apt.repos.intel.com/intel-gpg-keys/GPG-PUB-KEY-INTEL-SW-PRODUCTS.PUB | gpg --dearmor | sudo tee /usr/share/keyrings/oneapi-archive-keyring.gpg > /dev/null
echo "deb [signed-by=/usr/share/keyrings/oneapi-archive-keyring.gpg] https://apt.repos.intel.com/oneapi all main" | sudo tee /etc/apt/sources.list.d/oneAPI.list
sudo apt update && sudo apt install intel-basekit

Part 3: Install CUDA Toolkit Inside WSL2 (NVIDIA Only)

The Windows driver provides the CUDA runtime, but for development you need the full CUDA Toolkit inside WSL2.

  1. Add the CUDA Repository

    wget https://developer.download.nvidia.com/compute/cuda/repos/wsl-ubuntu/x86_64/cuda-keyring_1.1-1_all.deb
    sudo dpkg -i cuda-keyring_1.1-1_all.deb
    sudo apt update

  2. Install CUDA Toolkit

    sudo apt install cuda-toolkit-12-4

  3. Set Environment Variables

    Add the following lines to your ~/.bashrc or ~/.zshrc:

    export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH

    Apply the changes:

    source ~/.bashrc

  4. Verify CUDA Installation

    nvcc –version
    nvidia-smi

    Both commands should return version information without errors.


Part 4: Test GPU Acceleration

Run a Quick CUDA Sample (NVIDIA)

sudo apt install cuda-samples-12-4
cd /usr/local/cuda/samples/1_Utilities/deviceQuery
make
./deviceQuery

A result ending in Result = PASS confirms GPU acceleration is working correctly.

Test with PyTorch (All GPUs)

Install PyTorch inside WSL2:

pip install torch torchvision torchaudio

Run a quick validation:

import torch
print(torch.cuda.is_available())       # NVIDIA: should print True
print(torch.cuda.get_device_name(0))   # Prints your GPU name

For AMD GPUs, use the ROCm build of PyTorch available at pytorch.org.


Part 5: Optimize WSL2 Performance

Allocate More RAM and CPU Cores

Create or edit the file C:\Users\YourUser\.wslconfig:

[wsl2]
memory=16GB
processors=8
swap=4GB

Restart WSL2 for changes to take effect:

wsl --shutdown
wsl

Enable Sparse VHD to Reclaim Disk Space

wsl --manage Ubuntu --set-sparse true

Keep Project Files on the Linux Filesystem

For best I/O performance, store your project files inside the WSL2 filesystem (for example ~/projects/) rather than on the Windows-mounted /mnt/c/ path. Cross-filesystem operations are significantly slower and will bottleneck GPU pipelines that read large datasets.

For more ways to optimize your environment, check out our 2026 Ubuntu Life Hacks guide.


FAQ

Why does nvidia-smi work but my CUDA programs fail?

The Windows driver provides the CUDA runtime only. The CUDA Toolkit (compiler, headers, and libraries) must be installed separately inside WSL2. Follow Part 3 of this guide to install cuda-toolkit.

Can I run Docker with GPU support inside WSL2?

Yes. Install Docker Desktop for Windows with the WSL2 backend enabled. Then install the NVIDIA Container Toolkit inside WSL2:

sudo apt install nvidia-container-toolkit sudo nvidia-ctk runtime configure --runtime=docker sudo service docker restart
Test the setup with:

docker run --gpus all nvidia/cuda:12.4.0-base-ubuntu22.04 nvidia-smi

Is AMD ROCm support in WSL2 stable enough for production use?

ROCm on WSL2 has improved significantly since 2022. It works well for PyTorch and general compute workloads on RDNA 2 and RDNA 3 GPUs. Some CUDA-exclusive libraries have no AMD equivalent, but mainstream ML frameworks including PyTorch and TensorFlow support ROCm fully.

Can I use my GPU in WSL2 and Windows at the same time?

Yes. WSL2 uses GPU virtualization through WDDM, so your GPU is shared between Windows and WSL2 simultaneously. Heavy workloads running on both sides at the same time will compete for VRAM, but normal use has no conflicts.


Troubleshooting

ProblemLikely CauseFix
nvidia-smi not foundDriver not installed or WSL2 kernel outdatedUpdate Windows driver and run wsl --update
CUDA out of memory errorVRAM limit reachedReduce batch size or close other GPU apps on Windows
WSL2 crashes under loadInsufficient RAM allocatedIncrease memory= value in .wslconfig
Slow file read/writeProject files stored on /mnt/c/Move files to ~/ inside the WSL2 filesystem
rocminfo shows no GPUROCm not installed or missing group membershipRe-run sudo usermod -aG render,video $USER and reboot
nvcc command not foundCUDA Toolkit path not setAdd the export PATH line from Part 3 to your .bashrc

Summary

Setting up GPU acceleration in WSL2 comes down to one key rule: drivers live on Windows, toolkits live in Linux. Install the GPU driver on Windows, add the appropriate toolkit inside your WSL2 distro, validate with a quick test, and you are ready to run serious GPU workloads without leaving your Windows desktop.

Whether you are training models with PyTorch, running local LLMs with Ollama, or building CUDA applications from scratch, WSL2 on Windows 11 gives you a capable and low-friction Linux GPU environment right inside your existing workflow.

Now that your GPU is working in WSL2, a great next step is to set up a local LLM with Ollama to test your performance.

One thought on “How to Set Up WSL2 with GPU Acceleration on Windows 11 (NVIDIA, AMD and Intel)

Leave a Reply

Your email address will not be published. Required fields are marked *