Preparing nodes for GPU passthrough
For GPU passthrough, detach the GPU card that you want to attach to VMs from the host, and then enable IOMMU.
To detach a GPU card from a node
List all graphics cards on a node and obtain their VID and PID:
# lspci -nn | grep VGA 03:00.0 VGA compatible controller [0302]: NVIDIA Corporation TU104GL [Tesla T4] [10de:1eb8] (rev a1) 03:00.0 VGA compatible controller [0302]: NVIDIA Corporation TU104GL [Tesla T4] [10de:1eb8] (rev a1)
[10de:1eb8]
is the VID and PID of the graphics card.
Run the pci-helper.py
script to detach the chosen GPU specifying its VID and PID. For an NVIDIA graphics card, additionally blacklist the Nouveau driver. For example:
# /usr/libexec/vstorage-ui-agent/bin/pci-helper.py detach 10de:1eb8 --blacklist-nouveau
To enable IOMMU on a node
Run the pci-helper.py
script, and then reboot the node to apply the changes:
# /usr/libexec/vstorage-ui-agent/bin/pci-helper.py enable-iommu # reboot
The script works for both Intel and AMD processors.
You can check that IOMMU is successfully enabled in the dmesg
output:
# dmesg | grep -e DMAR -e IOMMU [ 0.000000] DMAR: IOMMU enabled