gpu passtrough moved to separate file

This commit is contained in:
Dobromir Popov
2025-11-22 14:48:58 +02:00
parent 23b4e1a8ee
commit 185d4f520b
6 changed files with 414 additions and 25 deletions

View File

@@ -2,12 +2,17 @@
This guide configures PCI passthrough for the AMD Strix Halo integrated GPU to the Windows Docker container, enabling GPU-accelerated applications.
## Important Note: Manual Binding Approach
This setup uses **manual GPU binding** to avoid host display issues. The GPU remains available to the host by default, and you manually bind it to VFIO only when starting the Windows container. This prevents system freezing at boot on newer kernels.
## Problem
The Windows container was showing "Red Hat VirtIO GPU DOD Controller" instead of the AMD GPU because:
- IOMMU was disabled (`amd_iommu=off`)
- GPU was not passed through at PCI level
- Only `/dev/dri` devices were exposed (insufficient for Windows)
- Early VFIO binding caused host display to freeze
## Solution Overview
@@ -23,50 +28,56 @@ The Windows container was showing "Red Hat VirtIO GPU DOD Controller" instead of
## Setup Instructions
### Step 1: Run Setup Script
### Step 1: Fix GRUB Configuration (If You Had Freezing Issues)
If your system was freezing at login on newer kernels:
```bash
cd /mnt/shared/DEV/repos/d-popov.com/scripts/portainer-compose-stacks/windows
sudo ./setup-gpu-passthrough.sh
sudo ./fix-grub-remove-vfio-ids.sh
```
This script will:
- Enable IOMMU in GRUB (`amd_iommu=on iommu=pt`)
- Configure VFIO to claim the GPU devices
- Update initramfs with VFIO modules
- Create necessary configuration files
This removes early VFIO binding that causes the host to lose GPU access.
### Step 2: Reboot
### Step 2: Update GRUB and Reboot
```bash
sudo update-grub
sudo reboot
```
**IMPORTANT**: The system MUST be rebooted for IOMMU and VFIO changes to take effect.
**IMPORTANT**: After reboot, IOMMU will be enabled but GPU remains available to host.
### Step 3: Verify Setup (After Reboot)
### Step 3: Before Starting Windows Container - Bind GPU
Every time you want to use GPU passthrough, run:
```bash
cd /mnt/shared/DEV/repos/d-popov.com/scripts/portainer-compose-stacks/windows
./verify-gpu-passthrough.sh
sudo ./bind-gpu-to-vfio.sh
```
Expected output:
- ✓ IOMMU is enabled
- ✓ vfio_pci module loaded
- ✓ GPU bound to vfio-pci
- ✓ Audio bound to vfio-pci
- ✓ /dev/vfio/vfio exists
This temporarily binds the GPU to VFIO (host display will stop working).
### Step 4: Start Windows Container
```bash
cd /mnt/shared/DEV/repos/d-popov.com/scripts/portainer-compose-stacks/windows
docker-compose down # Stop if running
docker-compose up -d
docker compose up -d
```
### Step 5: Install AMD Drivers in Windows
### Step 5: When Done - Restore GPU to Host
After stopping the Windows container, restore GPU to host:
```bash
cd /mnt/shared/DEV/repos/d-popov.com/scripts/portainer-compose-stacks/windows
sudo ./unbind-gpu-from-vfio.sh
```
This rebinds the GPU to amdgpu driver for host use.
### Step 6: Install AMD Drivers in Windows
1. Connect to Windows via RDP: `localhost:3389`
2. Open Device Manager