its pretty hard to setup but it can be done 😀

you should have TWO! Graphic-Cards – one onboard (does not need to be very powerfull) for displaying your host-linux – one to pass through to the VM (it will not be available for the host).

this was tested on:

hostnamectl
  Operating System: Debian GNU/Linux 9 (stretch)
            Kernel: Linux 4.9.0-4-amd64
      Architecture: x86-64

lspci 
00:00.0 Host bridge: Intel Corporation Skylake Host Bridge/DRAM Registers (rev 08)
00:02.0 VGA compatible controller: Intel Corporation HD Graphics 520 (rev 07)
00:08.0 System peripheral: Intel Corporation Skylake Gaussian Mixture Model
00:14.0 USB controller: Intel Corporation Sunrise Point-LP USB 3.0 xHCI Controller (rev 21)
00:14.2 Signal processing controller: Intel Corporation Sunrise Point-LP Thermal subsystem (rev 21)
00:17.0 SATA controller: Intel Corporation Sunrise Point-LP SATA Controller [AHCI mode] (rev 21)
00:1c.0 PCI bridge: Intel Corporation Device 9d12 (rev f1)
00:1e.0 Signal processing controller: Intel Corporation Sunrise Point-LP Serial IO UART Controller #0 (rev 21)
00:1f.0 ISA bridge: Intel Corporation Sunrise Point-LP LPC Controller (rev 21)
00:1f.2 Memory controller: Intel Corporation Sunrise Point-LP PMC (rev 21)
00:1f.3 Audio device: Intel Corporation Sunrise Point-LP HD Audio (rev 21)
00:1f.4 SMBus: Intel Corporation Sunrise Point-LP SMBus (rev 21)
00:1f.6 Ethernet controller: Intel Corporation Ethernet Connection I219-LM (rev 21)
01:00.0 Ethernet controller: Intel Corporation I211 Gigabit Network Connection (rev 03)

follow this excellent guide: https://davidyat.es/2016/09/08/gpu-passthrough/

for me those settings did work:

cat /etc/default/grub 

GRUB_DEFAULT=0
GRUB_TIMEOUT=0
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_iommu=oni pci_stub.ids=00:02.0"
GRUB_CMDLINE_LINUX=""

cat /etc/initramfs-tools/modules 
# List of modules that you want to include in your initramfs.
# They will be loaded at boot time in the order below.
#
# Syntax:  module_name [args ...]
#
# You must run update-initramfs(8) to effect this change.
#
# Examples:
#
# raid1
# sd_mod
pci_stub

a lot can go wrong…

you definately need a cpu with virtualization support (VT).

egrep '^flags.*(vmx|svm)' /proc/cpuinfo; # should display some output like

flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp
flags           : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch epb intel_pt tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp

should also display some output:

dmesg | grep pci_stub
[    0.000000] Command line: BOOT_IMAGE=/boot/vmlinuz-4.9.0-4-amd64 root=UUID=4287dcc2-278b-4413-9d59-10c1710f35bd ro quiet intel_iommu=oni pci_stub.ids=00:02.0
[    0.000000] Kernel command line: BOOT_IMAGE=/boot/vmlinuz-4.9.0-4-amd64 root=UUID=4287dcc2-278b-4413-9d59-10c1710f35bd ro quiet intel_iommu=oni pci_stub.ids=00:02.0
[  725.066667]  wmi efivars rfkill battery video intel_lpss_acpi intel_lpss mfd_core acpi_als tpm_infineon kfifo_buf acpi_pad industrialio button parport_pc ppdev lp parport efivarfs ip_tables x_tables autofs4 ext4 crc16 jbd2 crc32c_generic fscrypto ecb mbcache pci_stub hid_generic usbhid sd_mod crc32c_intel aesni_intel aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd psmouse e1000e igb ahci i2c_algo_bit libahci dca xhci_pci libata xhci_hcd i2c_i801 i2c_smbus ptp pps_core scsi_mod usbcore usb_common fan thermal i2c_hid hid
[  725.071478]  battery video intel_lpss_acpi intel_lpss mfd_core acpi_als tpm_infineon kfifo_buf acpi_pad industrialio button parport_pc ppdev lp parport efivarfs ip_tables x_tables autofs4 ext4 crc16 jbd2 crc32c_generic fscrypto ecb mbcache pci_stub hid_generic usbhid sd_mod crc32c_intel aesni_intel aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd psmouse e1000e igb ahci i2c_algo_bit libahci dca xhci_pci libata xhci_hcd i2c_i801 i2c_smbus ptp pps_core scsi_mod usbcore usb_common fan thermal i2c_hid hid
[  725.071890]  wmi efivars rfkill battery video intel_lpss_acpi intel_lpss mfd_core acpi_als tpm_infineon kfifo_buf acpi_pad industrialio button parport_pc ppdev lp parport efivarfs ip_tables x_tables autofs4 ext4 crc16 jbd2 crc32c_generic fscrypto ecb mbcache pci_stub hid_generic usbhid sd_mod crc32c_intel aesni_intel aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd psmouse e1000e igb ahci i2c_algo_bit libahci dca xhci_pci libata xhci_hcd i2c_i801 i2c_smbus ptp pps_core scsi_mod usbcore usb_common fan thermal i2c_hid hid
[  725.072241]  wmi efivars rfkill battery video intel_lpss_acpi intel_lpss mfd_core acpi_als tpm_infineon kfifo_buf acpi_pad industrialio button parport_pc ppdev lp parport efivarfs ip_tables x_tables autofs4 ext4 crc16 jbd2 crc32c_generic fscrypto ecb mbcache pci_stub hid_generic usbhid sd_mod crc32c_intel aesni_intel aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd psmouse e1000e igb ahci i2c_algo_bit libahci dca xhci_pci libata xhci_hcd i2c_i801 i2c_smbus ptp pps_core scsi_mod usbcore usb_common fan thermal i2c_hid hid
[  725.079004]  wmi efivars rfkill battery video intel_lpss_acpi intel_lpss mfd_core acpi_als tpm_infineon kfifo_buf acpi_pad industrialio button parport_pc ppdev lp parport efivarfs ip_tables x_tables autofs4 ext4 crc16 jbd2 crc32c_generic fscrypto ecb mbcache pci_stub hid_generic usbhid sd_mod crc32c_intel aesni_intel aes_x86_64 glue_helper lrw gf128mul ablk_helper cryptd psmouse e1000e igb ahci i2c_algo_bit libahci dca xhci_pci libata xhci_hcd i2c_i801 i2c_smbus ptp pps_core scsi_mod usbcore usb_common fan thermal i2c_hid hid

inside virt-manager:

  1. open the vm
  2. go to „connection details“
  3. r-click in the list of devices and + add device
  4. under pci-devices select your dedicated graphic card

run the VM… if your screen gets dark and even your keyboard passess out… than you only have one graphic card.

maybe install vncserver inside the windows vm prior to that.

install drivers for your graphic card

now you should see device manager should show the correct naming of your chip model…

not just „Default-VGA-Graphic“…. or something is wrong.

fire up some basic 3d benchmark http://www.geeks3d.com/20140304/gputest-0-7-0-opengl-benchmark-win-linux-osx-new-fp64-opengl-4-test-and-online-gpu-database/

or the more advanced 😀 Heaven 4.0 Benchmark

it is amazing that KVM can do this… VirtualBox virtual graphic card adapter is unfortunately not often recognized correctly by 3d applications…

but you will need two graphic cards… like one on board and one dedicated PCI device.

admin