Files
light-heart-labs--dreamserver/ods/docs/WSL2-GPU-PASSTHROUGH.md
T
wehub-resource-sync 9e8f1bbeed
Dashboard / frontend (push) Failing after 0s
Dashboard / api (push) Failing after 0s
Lint PowerShell / powershell-lint (ubuntu-latest) (push) Failing after 1s
Python Lint / Lint Python with Ruff (push) Failing after 1s
ShellCheck / Lint shell scripts (push) Failing after 1s
Matrix Smoke / linux-smoke (push) Failing after 1s
Matrix Smoke / distro: cachyos (push) Failing after 15s
Matrix Smoke / distro: linux-mint-21.3 (push) Failing after 15s
Matrix Smoke / distro: debian-12 (push) Failing after 5m21s
Matrix Smoke / distro: fedora-41 (push) Failing after 4m56s
Matrix Smoke / distro: ubuntu-24.04 (push) Failing after 2m13s
Matrix Smoke / distro: rocky-9 (push) Failing after 10m39s
Matrix Smoke / distro: manjaro (push) Failing after 12m11s
Matrix Smoke / distro: opensuse-tw (push) Failing after 11m53s
Matrix Smoke / distro: archlinux (push) Failing after 20m3s
Matrix Smoke / distro: ubuntu-22.04 (push) Failing after 13m49s
Validate .env Schema / tier-1-env-validation (push) Successful in 52s
Validate .env Schema / tier-2-env-validation (push) Successful in 44s
Validate .env Schema / tier-3-env-validation (push) Successful in 52s
Validate .env Schema / tier-4-env-validation (push) Successful in 51s
Validate Extensions Catalog / Check catalog is up-to-date (push) Failing after 9m47s
Secret Scan / Scan for secrets (push) Failing after 21m4s
Validate Docker Compose / Validate Docker Compose files (push) Has been cancelled
Python Type Check / Type check with mypy (push) Has been cancelled
Validate .env Schema / tier-0-env-validation (push) Has been cancelled
Test Linux / integration-smoke (push) Has been cancelled
Lint PowerShell / powershell-lint (windows-latest) (push) Has been cancelled
Matrix Smoke / macos-smoke (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 12:31:33 +08:00

95 lines
3.3 KiB
Markdown

# WSL2 GPU Passthrough for Running Local AI Models
## 1. Prerequisites
### Windows Version
Ensure you are running **Windows 10 version 2004 or later** (Build 19041) or **Windows 11**.
### GPU Drivers
- Install the latest NVIDIA drivers from the [NVIDIA website](https://www.nvidia.com/Download/index.aspx).
- Ensure the drivers support WSL 2 GPU passthrough. You can check compatibility on the NVIDIA Driver Downloads page.
### WSL2 Version
Make sure WSL2 is installed and updated:
```bash
wsl --update
```
## 2. Step-by-Step Enable GPU Passthrough for WSL2
### Install WSL2 and a Linux Distribution
If not already installed, install WSL2 and a Linux distribution (e.g., Ubuntu):
```bash
wsl --install -d Ubuntu
```
### Set WSL2 as the Default Version
Ensure WSL2 is set as the default version:
```bash
wsl --set-default-version 2
```
### Install the NVIDIA Container Toolkit
Inside your WSL2 distribution, install the NVIDIA Container Toolkit:
```bash
sudo apt-get update
sudo apt-get install -y nvidia-driver-510
sudo apt-get install -y nvidia-container-toolkit
sudo systemctl restart docker
```
### Enable GPU Support in WSL2
Edit the `.wslconfig` file in your Windows user directory (`C:\Users\<YourUsername>`):
```ini
[wsl2]
gpu=true
memory=8GB # Adjust as needed
processors=4 # Adjust as needed
```
Restart WSL2:
```bash
wsl --shutdown
wsl --distribution Ubuntu
```
## 3. Verifying GPU is Visible Inside WSL2
Run `nvidia-smi` to verify the GPU is recognized:
```bash
nvidia-smi
```
You should see output similar to this:
```
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 510.85.02 Driver Version: 510.85.02 CUDA Version: 11.6 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce GTX 165... Off | 00000000:01:00.0 Off | N/A |
| N/A 41C P8 9W / 175W | 0MiB / 4096MiB | 0% Default |
| | | N/A |
+-----------------------------------------------------------------------------+
```
## 4. Common Issues and Fixes
### Driver Version Mismatch
Ensure that the NVIDIA drivers installed on Windows match those expected by the NVIDIA Container Toolkit in WSL2. Reinstall the drivers if necessary.
### CUDA Not Found
Install CUDA in your WSL2 distribution if it's not already installed:
```bash
sudo apt-get install -y cuda
```
Verify the installation by checking the CUDA version:
```bash
cuda --version
```
## 5. Performance Expectations vs Native Linux
Running AI models in WSL2 with GPU passthrough offers significant performance benefits compared to CPU-only execution. However, there may still be some overhead compared to native Linux due to the virtualization layer. For most practical purposes, the performance should be close to native Linux.
This guide should help you set up and verify GPU passthrough for WSL2, enabling you to run local AI models efficiently on your Windows machine.