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, typewinver, 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
- Download the latest Game Ready or Studio Driver from the NVIDIA website
- Install it normally on Windows 11
- 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
- Download the latest Adrenalin Edition driver from the AMD support page
- Install it on Windows 11. ROCm support in WSL2 is included in drivers from 2022 onward
- 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
- Install the latest Intel Arc and Iris Xe Graphics driver from the Intel website
- 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.
- 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 - Install CUDA Toolkit
sudo apt install cuda-toolkit-12-4
- Set Environment Variables
Add the following lines to your
~/.bashrcor~/.zshrc:export PATH=/usr/local/cuda/bin:$PATH export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
Apply the changes:source ~/.bashrc - 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
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.
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
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.
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
| Problem | Likely Cause | Fix |
|---|---|---|
nvidia-smi not found | Driver not installed or WSL2 kernel outdated | Update Windows driver and run wsl --update |
| CUDA out of memory error | VRAM limit reached | Reduce batch size or close other GPU apps on Windows |
| WSL2 crashes under load | Insufficient RAM allocated | Increase memory= value in .wslconfig |
| Slow file read/write | Project files stored on /mnt/c/ | Move files to ~/ inside the WSL2 filesystem |
rocminfo shows no GPU | ROCm not installed or missing group membership | Re-run sudo usermod -aG render,video $USER and reboot |
nvcc command not found | CUDA Toolkit path not set | Add 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)”