i915 Intel Integrated GPU passthrough to Linux(ubuntu) VM on PVE 7.4
PVE version 7.4
Host machine: Intel N100 (4 cores with Intel Integrated GPU), 32G DDR5 RAM, 1T NVME SSD.
VM: Ubuntu 22.04 x86_64 for desktop
For more infomation about how to prepare PVE for GPU passthrough, please read my another blog: https://www.cnblogs.com/spaceship9/p/17410689.html
Also, please read this link about install i915 kernel modules on PVE host machines which need specific Linux kernels: https://github.com/strongtz/i915-sriov-dkms
So here words in short. What you need to do after you prepared PVE for GPU passthrough on the host machine?
1. Change Kernel to 6.1.x on Linux (Ubuntu 22.04)
1.1 Install specific 6.1.x kernel
On ubuntu 22.04, by default it doesn't come with kernel 6.1.x, so you'll have to install a package called: mainline
# install a package called mainline available from the cappelikan personal package archive (PPA) sudo add-apt-repository ppa:cappelikan/ppa # update and install the package sudo apt update sudo apt install mainline
Then open the app: mainline kernels on your desktop
Click on the kernel and install it. In this case, I manualy installed the kernel version 6.1.74. Other kernels those come with the Ubuntu logo are offically delivered from Ubuntu.
1.2 Set boot from the specific kernel
Helpful tutorial from here: https://gist.github.com/chaiyujin/c08e59752c3e238ff3b1a5098322b363
Set GRUB Default Kernel
- Find entrance from
/boot/grub/grub.cfg
- Get the $menuentry_id_option:
grep submenu /boot/grub/grub.cfg
submenu 'Advanced options for Ubuntu' $menuentry_id_option 'gnulinux-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf' {
'gnulinux-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf'
is what we need. - Get the specific kernel option:
grep gnulinux-4.15.0 /boot/grub/grub.cfg
menuentry 'Ubuntu, with Linux 4.15.0-126-generic' --class ubuntu --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-4.15.0-126-generic-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf' {
'gnulinux-4.15.0-126-generic-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf'
is what we need.
- Get the $menuentry_id_option:
- Set GRUB_DEFAULT in
/etc/default/grub
- Join two entry strings obtained above by '>', set to
GRUB_DEFAULT
.GRUB_DEFAULT='gnulinux-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf>gnulinux-4.15.0-126-generic-advanced-4591a659-55e2-4bec-8dbe-d98bd9e489cf'
- Join two entry strings obtained above by '>', set to
- Update grub
sudo update-grub
- Reboot the machine
Words in short, in my case
# If you change this file, run 'update-grub' afterwards to update # /boot/grub/grub.cfg. # For full documentation of the options in this file, see: # info -f grub -n 'Simple configuration' #GRUB_DEFAULT=0 GRUB_DEFAULT='gnulinux-advanced-f2138d3d-ce81-47df-b51e-22fd0f874518>gnulinux-6.1.74-060174-generic-advanced-f2138d3d-ce81-47df-b51e-22fd0f874518' #GRUB_TIMEOUT_STYLE=hidden GRUB_TIMEOUT_STYLE=menu GRUB_TIMEOUT=5 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian` #GRUB_CMDLINE_LINUX_DEFAULT="quiet splash" GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.enable_guc=3" GRUB_CMDLINE_LINUX=""
Explanation:
Change a line, and use specific kernel.
GRUB_DEFAULT='gnulinux-advanced-f2138d3d-ce81-47df-b51e-22fd0f874518>gnulinux-6.1.74-060174-generic-advanced-f2138d3d-ce81-47df-b51e-22fd0f874518'
Add one line to enable i915 intel integrated GPU passthrough when the kernel will be loaded
GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.enable_guc=3"
Then
sudo update-grub
Then reboot the VM
2. Build and Install i915 kernel modules for Kernel 6.1.x
Because the kernel from Ubuntu PPA package **mainline** comes with the settings (.config for kernel) as below
CONFIG_INTEL_MEI_PXP=m
CONFIG_DRM_I915_PXP=y
(To know your loaded kernel's settings, look for the file /boot/config-6.1.xxxxx, in my case it's /boot/config-6.1.74-060174-generic )
So I DON'T need to rebuild this kernel AGAIN, I ONLY NEED TO INSTALL THE i915 kernel module.
Follow these steps
- Build and install the i915-sriov module
cd /usr/src
git clone https://github.com/strongtz/i915-sriov-dkms i915-sriov-dkms-6.1
edit /usr/src/i915-sriov-dkms-6.1/dkms.conf with the following:
PACKAGE_NAME="i915-sriov-dkms"
PACKAGE_VERSION="6.1"
dkms install --force -m i915-sriov-dkms -v 6.1
edit /etc/default/grub with the following:
GRUB_CMDLINE_LINUX_DEFAULT="quiet i915.enable_guc=3"
update-grub
update-initramfs -u
poweroff
Then you need to add the device in the PVE host
In Proxmox, add one of the 0000:xx:xx.xx devices to the VM, then start the VM
in my case it's
It's recommended to use bios with UEFI, but I didn't use it. Instead, I used SeaBIOS by default and it worked as well.
For Display, set VirtIO-GPU (virtio).
To verifiy whether the i915 kernel module is loaded,
$ lspci | grep -i vga 00:02.0 VGA compatible controller: Red Hat, Inc. Virtio GPU (rev 01) 00:10.0 VGA compatible controller: Intel Corporation Device 46d1
Intel Corporation Device 46d1 (The GPU from Intel N100)
$ lspci -vs 00:10.0 00:10.0 VGA compatible controller: Intel Corporation Device 46d1 (prog-if 00 [VGA controller]) Subsystem: Intel Corporation Device 7270 Physical Slot: 16 Flags: bus master, fast devsel, latency 0, IRQ 39 Memory at fd000000 (64-bit, non-prefetchable) [size=16M] Memory at c0000000 (64-bit, prefetchable) [size=512M] Expansion ROM at 000c0000 [virtual] [disabled] [size=128K] Capabilities: <access denied> Kernel driver in use: i915 Kernel modules: i915
(base) alex@ubuntu-vm:~$ sudo dmesg | grep i915 [ 0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-6.1.74-060174-generic root=UUID=f2138d3d-ce81-47df-b51e-22fd0f874518 ro quiet i915.enable_guc=3 [ 0.048332] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-6.1.74-060174-generic root=UUID=f2138d3d-ce81-47df-b51e-22fd0f874518 ro quiet i915.enable_guc=3 [ 3.254861] i915: loading out-of-tree module taints kernel. [ 3.266701] i915: module verification failed: signature and/or required key missing - tainting kernel [ 3.819490] i915 0000:00:10.0: Running in SR-IOV VF mode [ 3.821613] i915 0000:00:10.0: [drm] GT0: GUC: interface version 0.1.0.0 [ 3.826274] i915 0000:00:10.0: [drm] Using Transparent Hugepages [ 3.833602] i915 0000:00:10.0: [drm] GT0: GUC: interface version 0.1.0.0 [ 3.834450] i915 0000:00:10.0: GuC firmware PRELOADED version 1.0 submission:SR-IOV VF [ 3.834458] i915 0000:00:10.0: HuC firmware PRELOADED [ 3.854547] i915 0000:00:10.0: [drm] Protected Xe Path (PXP) protected content support initialized [ 3.854568] i915 0000:00:10.0: [drm] PMU not supported for this GPU. [ 3.855538] [drm] Initialized i915 1.6.0 20201103 for 0000:00:10.0 on minor 1 [ 6.644936] i915 0000:00:10.0: vgaarb: changed VGA decodes: olddecodes=io+mem,decodes=none:owns=mem
ls /dev/dri/render*
/dev/dri/renderD128 /dev/dri/renderD129
vainfo libva info: VA-API version 1.14.0 libva error: vaGetDriverNameByIndex() failed with unknown libva error, driver_name = (null) vaInitialize failed with error code -1 (unknown libva error),exit
The vainfo had some errors. I think it's because the iGPU from N100 doesn't come with any specific name. It's only called as
Intel Corporation Device 46d1
3. Enable remote control
Go to settings in Ubuntu,
Sharing -> Remote Desktop (set on)
Sharing -> Remote Login (set on)
In remote Desktop, set specific password for remote login only. The password can be different from your user password.
Now you can remotely connect to your Linux(Ubuntu) VM from other computers.
And I feel it's way more smoother than viewing the VM console on PVE's web admin pages. You can easily copy and past in and out on Client.