148 lines
3.1 KiB
Markdown
148 lines
3.1 KiB
Markdown
# GPU Passthrough (VFIO) Notes
|
||
|
||
Host/guest checklist for GPU passthrough (or virtual GPU) when building Debian VMs in Proxmox / virt-manager style setups.
|
||
|
||
---
|
||
|
||
## Host: Pick GPU and enable passthrough
|
||
|
||
List GPUs on the host:
|
||
|
||
```bash
|
||
lspci | egrep -i 'vga|3d|display'
|
||
```
|
||
|
||
Note the PCI ID of the card you want to pass, e.g. `0000:01:00.0`.
|
||
|
||
On the host, enable IOMMU and passthrough (Proxmox/virt-manager style):
|
||
|
||
- Add appropriate kernel params (example Intel):
|
||
|
||
```text
|
||
intel_iommu=on iommu=pt
|
||
```
|
||
|
||
- Reboot and verify:
|
||
|
||
```bash
|
||
dmesg | egrep -i 'iommu|dmar'
|
||
```
|
||
|
||
Bind the GPU to `vfio` (or equivalent passthrough driver) on the host so the VM can own it exclusively.
|
||
|
||
---
|
||
|
||
## Host: Create the VM with a VGA/GPU device
|
||
|
||
Create a new VM (Proxmox or virt-manager):
|
||
|
||
- **Firmware**: UEFI/OVMF if possible
|
||
- **Machine type**: Q35/modern
|
||
- **CPU**: host-passthrough (or similar)
|
||
|
||
Add GPU to the VM:
|
||
|
||
- Add PCI device: select your GPU (and its audio function if present)
|
||
- For a purely virtual GPU instead (no passthrough), pick Virtio GPU or QXL as the display adapter
|
||
|
||
Add display channel:
|
||
|
||
- If you want a normal graphical console, use SPICE (virt-manager) or Proxmox’s standard console display
|
||
- Add a Channel (spice) device for clipboard/resize when using SPICE
|
||
|
||
---
|
||
|
||
## Guest: Verify what GPU the VM sees
|
||
|
||
Inside the guest OS (your Debian VM):
|
||
|
||
```bash
|
||
lspci | egrep -i 'vga|3d|display'
|
||
lsmod | egrep 'nvidia|amdgpu|radeon|virtio_gpu'
|
||
```
|
||
|
||
Interpretation:
|
||
|
||
- `NVIDIA Corporation ...` → real NVIDIA passthrough
|
||
- `Advanced Micro Devices, Inc. [AMD/ATI] ...` → AMD passthrough
|
||
- `Red Hat, Inc. Virtio GPU` or `QXL` → virtual GPU only
|
||
|
||
---
|
||
|
||
## Guest: Install and test drivers
|
||
|
||
### If NVIDIA passthrough
|
||
|
||
Install driver and tools:
|
||
|
||
```bash
|
||
sudo apt update
|
||
sudo apt install nvidia-driver-535 nvidia-smi
|
||
```
|
||
|
||
(Adjust version to what Debian suggests.)
|
||
|
||
Test:
|
||
|
||
```bash
|
||
nvidia-smi
|
||
watch -n 1 nvidia-smi
|
||
```
|
||
|
||
The watch line must be `watch -n 1 nvidia-smi`.
|
||
|
||
Quick 3D check:
|
||
|
||
```bash
|
||
sudo apt install mesa-utils
|
||
glxgears
|
||
```
|
||
|
||
GPU utilization should rise in `nvidia-smi` while `glxgears` runs.
|
||
|
||
### If AMD passthrough
|
||
|
||
Inspect and ensure `amdgpu` is used:
|
||
|
||
```bash
|
||
sudo lshw -c video
|
||
lsmod | grep amdgpu
|
||
```
|
||
|
||
Install tools:
|
||
|
||
```bash
|
||
sudo apt install mesa-utils
|
||
# optionally:
|
||
sudo apt install amdgpu-tools # or ROCm SMI tools if available
|
||
```
|
||
|
||
Monitor:
|
||
|
||
```bash
|
||
watch -n 1 sudo amd-smi
|
||
```
|
||
|
||
(Or the ROCm SMI CLI in your distro.)
|
||
|
||
### If only Virtio/QXL is present
|
||
|
||
- You have a virtual GPU, not the physical one.
|
||
- You can still use `glxgears` and basic acceleration, but host GPU usage is not controlled directly from inside this VM.
|
||
- To use the physical card, change the VM to PCI passthrough as above.
|
||
|
||
---
|
||
|
||
## Guest: Console and SPICE/GUI behavior
|
||
|
||
- With SPICE display and the spice channel present, dynamic resolution and clipboard should work once guest tools are installed.
|
||
- If a graphical display manager (e.g. LightDM) misbehaves, you can force a TTY-only boot:
|
||
|
||
```bash
|
||
sudo systemctl set-default multi-user.target
|
||
sudo systemctl disable --now lightdm.service
|
||
```
|
||
|
||
This gives you a reliable text console, and you can work purely over SSH for GPU workloads.
|
||
|