ubuntu:gpu:gpu_pass-through
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
ubuntu:gpu:gpu_pass-through [2023/06/25 11:26] – peter | ubuntu:gpu:gpu_pass-through [2023/06/25 11:32] (current) – peter | ||
---|---|---|---|
Line 5: | Line 5: | ||
---- | ---- | ||
- | ===== Verify the host environment supports | + | [[Ubuntu: |
- | TODO: | + | [[Ubuntu:GPU:GPU pass-through: |
- | + | ||
- | + | ||
- | ---- | + | |
- | + | ||
- | ===== Enable IOMMU ===== | + | |
- | + | ||
- | **IOMMU** is usually disabled by default. | + | |
- | + | ||
- | * It needs to be enable at boot time in the **/ | + | |
- | + | ||
- | For AMD-based hosts: | + | |
- | + | ||
- | <file bash / | + | |
- | GRUB_CMDLINE_LINUX=" | + | |
- | </ | + | |
- | + | ||
- | For Intel-based hosts: | + | |
- | + | ||
- | <file bash / | + | |
- | GRUB_CMDLINE_LINUX=" | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ===== Re-generate the main GRUB 2 configuration file ===== | + | |
- | + | ||
- | The GRUB 2 configuration file is **/ | + | |
- | + | ||
- | <code bash> | + | |
- | sudo grub2-mkconfig -o / | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ===== Reboot ===== | + | |
- | + | ||
- | + | ||
- | ---- | + | |
- | + | ||
- | ===== Verify that IOMMU is enabled ===== | + | |
- | + | ||
- | <code bash> | + | |
- | sudo dmesg | grep -e DMAR -e IOMMU | + | |
- | </ | + | |
- | + | ||
- | returns: | + | |
- | + | ||
- | <code bash> | + | |
- | [ | + | |
- | [ | + | |
- | [ 2.176924] perf/ | + | |
- | [ 3.875165] AMD-Vi: AMD IOMMUv2 loaded and initialized | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ===== Blacklist the Nouveau driver ===== | + | |
- | + | ||
- | Prevent the host OS from loading the built-in nouveau driver. | + | |
- | + | ||
- | Create the file **/ | + | |
- | + | ||
- | <file bash / | + | |
- | blacklist nouveau | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ===== Configure VFIO and isolate the GPU used for pass-through | + | |
- | + | ||
- | Find the card vendor and model IDs. | + | |
- | + | ||
- | <code bash> | + | |
- | lspci -k | grep VGA | + | |
- | </ | + | |
- | + | ||
- | returns: | + | |
- | + | ||
- | <code bash> | + | |
- | 0c:00.0 VGA compatible controller: Advanced Micro Devices, Inc. [AMD/ATI] Navi 31 [Radeon RX 7900 XT/7900 XTX] (rev c8) | + | |
- | </ | + | |
- | + | ||
- | <WRAP info> | + | |
- | **NOTE: | + | |
- | </ | + | |
- | + | ||
- | + | ||
- | ---- | + | |
- | + | ||
- | ===== Get the device ID ===== | + | |
- | + | ||
- | Using the Bus number identified earlier. | + | |
- | + | ||
- | <code bash> | + | |
- | lspci -nn | grep 0c:00.0 | + | |
- | </ | + | |
- | + | ||
- | returns: | + | |
- | + | ||
- | <code bash> | + | |
- | 0c:00.0 VGA compatible controller [0300]: Advanced Micro Devices, Inc. [AMD/ATI] Navi 31 [Radeon RX 7900 XT/7900 XTX] [1002:744c] (rev c8) | + | |
- | </ | + | |
- | + | ||
- | <WRAP info> | + | |
- | **NOTE: | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ===== Create a module VFIO file ===== | + | |
- | + | ||
- | Create the file **/ | + | |
- | + | ||
- | <file bash / | + | |
- | options vfio-pci ids=1002: | + | |
- | </ | + | |
- | + | ||
- | <WRAP info> | + | |
- | **NOTE: | + | |
- | + | ||
- | * For some cards, the audio device must be specified too, so that ID must also be added to the list, otherwise the card will be unusable. | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ===== Load the VFIO driver ===== | + | |
- | + | ||
- | There are various ways you can load the VFIO driver: | + | |
- | + | ||
- | ==== Including the driver in the initrd file ==== | + | |
- | + | ||
- | Create the file **/ | + | |
- | + | ||
- | <file | + | |
- | add_drivers+=" | + | |
- | </ | + | |
- | + | ||
- | Re-generate the initrd file: | + | |
- | + | ||
- | <code bash> | + | |
- | sudo dracut --force / | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ==== Adding the driver to the list of auto-loaded modules ==== | + | |
- | + | ||
- | Create the file **/ | + | |
- | + | ||
- | <file bash / | + | |
- | vfio | + | |
- | vfio_iommu_type1 | + | |
- | vfio_pci | + | |
- | kvm | + | |
- | kvm_intel | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
- | + | ||
- | ==== Load the driver manually ==== | + | |
- | + | ||
- | To load the driver manually at runtime: | + | |
- | + | ||
- | <code bash> | + | |
- | sudo modprobe vfio-pci | + | |
- | </ | + | |
- | + | ||
- | ---- | + | |
ubuntu/gpu/gpu_pass-through.1687692415.txt.gz · Last modified: 2023/06/25 11:26 by peter