GPU virtualization explained
GPU virtualization refers to technologies that allow the use of a GPU to accelerate graphics or GPGPU applications running on a virtual machine. GPU virtualization is used in various applications such as desktop virtualization, cloud gaming[1] and computational science (e.g. hydrodynamics simulations).
GPU virtualization implementations generally involve one or more of the following techniques: device emulation, API remoting, fixed pass-through and mediated pass-through. Each technique presents different trade-offs regarding virtual machine to GPU consolidation ratio, graphics acceleration, rendering fidelity and feature support, portability to different hardware, isolation between virtual machines, and support for suspending/resuming and live migration.[2] [3] [4] [5]
API remoting
In API remoting or API forwarding, calls to graphical APIs from guest applications are forwarded to the host by remote procedure call, and the host then executes graphical commands from multiple guests using the host's GPU as a single user.[2] It may be considered a form of paravirtualization when combined with device emulation.[6] This technique allows sharing GPU resources between multiple guests and the host when the GPU does not support hardware-assisted virtualization. It is conceptually simple to implement, but it has several disadvantages:[2]
- In pure API remoting, there is little isolation between virtual machines when accessing graphical APIs; isolation can be improved using paravirtualization
- Performance ranges from 86% to as low as 12% of native performance in applications that issue a large number of drawing calls per frame
- A large number of API entry points must be forwarded, and partial implementation of entry points may decrease fidelity
- Applications on guest machines may be limited to few available APIs
Hypervisors usually use shared memory between guest and host to maximize performance and minimize latency. Using a network interface instead (a common approach in distributed rendering), third-party software can add support for specific APIs (e.g. rCUDA[7] for CUDA) or add support for typical APIs (e.g. VMGL[8] for OpenGL) when it is not supported by the hypervisor's software package, although network delay and serialization overhead may outweigh the benefits.
Fixed pass-through
In fixed pass-through or GPU pass-through (a special case of PCI pass-through), a GPU is accessed directly by a single virtual machine exclusively and permanently. This technique achieves 96100% of native performance[22] and high fidelity,[2] but the acceleration provided by the GPU cannot be shared between multiple virtual machines. As such, it has the lowest consolidation ratio and the highest cost, as each graphics-accelerated virtual machine requires an additional physical GPU.[2]
The following software technologies implement fixed pass-through:
VirtualBox removed support for PCI pass-through in version 6.1.0.[31]
QEMU/KVM
For certain GPU models, Nvidia and AMD video card drivers attempt to detect the GPU is being accessed by a virtual machine and disable some or all GPU features.[32] NVIDIA has recently changed virtualization rules for consumer GPUs by disabling the check in GeForce Game Ready driver 465.xx and later.[33]
For NVIDIA, various architectures of desktop and laptop consumer GPUs can be passed through in various ways. For desktop graphics cards, passthrough can be done via the KVM using either the legacy or UEFI BIOS configuration via SeaBIOS and OVMF, respectively.
NVIDIA
Desktops
For desktops, most graphics cards can be passed through, although for graphics cards with the Pascal architecture or older, the VBIOS of the graphics card must be passed through in the virtual machine if the GPU is used to boot the host.[34]
Laptops
For laptops, the NVIDIA driver checks for the presence of a battery via ACPI, and without a battery, an error will be returned. To avoid this, an acpitable created from text converted into Base64 is required to spoof a battery and bypass the check.
Pascal and earlier
For the laptop graphics cards that are Pascal and older, passthrough varies widely on the configuration of the graphics card. For laptops that do not have NVIDIA Optimus, such as the MXM variants, passthrough can be achieved through traditional methods. For laptops that have NVIDIA Optimus on as well as rendering through the CPU's integrated graphics framebuffer as opposed to its own, the passthrough is more complicated, requiring a remote rendering display or service, the use of Intel GVT-g, as well as integrating the VBIOS into the boot configuration due to the VBIOS being present in the laptop's system BIOS as opposed to the GPU itself. For laptops that have a GPU with NVIDIA Optimus and have a dedicated framebuffer, the configurations may vary. If NVIDIA Optimus can be switched off, then passthrough is possible through traditional means. However, if Optimus is the only configuration, then it is most likely that the VBIOS is present in the laptop's system BIOS, requiring the same steps as the laptop rendering only on the integrated graphics framebuffer, but an external monitor is also possible.[35]
Mediated pass-through
In mediated device pass-through or full GPU virtualization, the GPU hardware provides contexts with virtual memory ranges for each guest through IOMMU and the hypervisor sends graphical commands from guests directly to the GPU. This technique is a form of hardware-assisted virtualization and achieves near-native performance and high fidelity. If the hardware exposes contexts as full logical devices, then guests can use any API. Otherwise, APIs and drivers must manage the additional complexity of GPU contexts. As a disadvantage, there may be little isolation between virtual machines when accessing GPU resources.[2]
The following software and hardware technologies implement mediated pass-through:
While API remoting is generally available for current and older GPUs, mediated pass-through requires hardware support available only on specific devices.
Device emulation
GPU architectures are very complex and change quickly, and their internal details are often kept secret. It is generally not feasible to fully virtualize new generations of GPUs, only older and simpler generations. For example, PCem, a specialized emulator of the IBM PC architecture, can emulate a S3 ViRGE/DX graphics device, which supports Direct3D 3, and a 3dfx Voodoo2, which supports Glide, among others.[43]
When using a VGA or an SVGA virtual display adapter,[44] [45] [46] the guest may not have 3D graphics acceleration, providing only minimal functionality to allow access to the machine via a graphics terminal. The emulated device may expose only basic 2D graphics modes to guests. The virtual machine manager may also provide common API implementations using software rendering to enable 3D graphics applications on the guest, albeit at speeds that may be low as 3% of hardware-accelerated native performance.[2] The following software technologies implement graphics APIs using software rendering:
See also
Notes and References
- Hong . Hua-Jun . Fan-Chiang . Tao-Ya . Lee . Che-Rung . Chen . Kuan-Ta . Huang . Chun-Ying . Hsu . Cheng-Hsin . GPU Consolidation for Cloud Games: Are We There Yet? . 13th Annual Workshop on Network and Systems Support for Games . . 1–6 . 10.1109/NetGames.2014.7008969 . 978-1-4799-6882-4 . 2156-8138 . . 2014 . 664129 . 14 September 2020.
- Dowty . Micah . Sugerman . Jeremy . GPU Virtualization on VMware's Hosted I/O Architecture . ACM SIGOPS Operating Systems Review . . 43 . 3 . 73–82 . . . 10.1145/1618525.1618534 . 0163-5980 . July 2009 . 228328 . 10 September 2020.
- Yu . Hangchen . Rossbach . Christopher . Full Virtualization for GPUs Reconsidered . ISCA-44 14th Annual Workshop on Duplicating, Deconstructing and Debunking . . 25 June 2017 . 12 September 2020.
- Tian . Kun . Dong . Yaozu . Cowperthwaite . David . A Full GPU Virtualization Solution with Mediated Pass-Through . . . Proceedings of the 2014 USENIX Conference on USENIX Annual Technical Conference (USENIX ATC'14) . 121–132 . 978-1-931971-10-2 . . June 2014 .
- Gottschlag . Mathias . Hillenbrand . Marius . Kehne . Jens . Stoess . Jan . Bellosa . Frank . LoGV: Low-Overhead GPGPU Virtualization . . . 1721–1726 . 10.1109/HPCC.and.EUC.2013.245 . 978-0-7695-5088-6 . . November 2013 . 16 September 2020.
- Suzuki . Yusuke . Kato . Shinpei . Yamada . Hiroshi . Kono . Kenji . GPUvm: Why Not Virtualizing GPUs at the Hypervisor? . . . Proceedings of the 2014 USENIX Conference on USENIX Annual Technical Conference (USENIX ATC'14) . 109–120 . 978-1-931971-10-2 . . June 2014 . 14 September 2020.
- Duato . José . Peña . Antonio . Silla . Federico . Fernández . Juan . Mayo . Rafael . Quintana-Ortí . Enrique . Enabling CUDA acceleration within virtual machines using rCUDA . . . . 1–10 . 10.1109/HiPC.2011.6152718 . 978-1-4577-1951-6 . 1094-7256 . . December 2011 . 13 September 2020. 2117/168226 . free .
- Lagar-Cavilla . Horacio . Tolia . Niraj . Satyanarayanan . Mahadev . Lara . Eyal . VMM-Independent Graphics Acceleration . VEE '07 . . Proceedings of the 3rd International Conference on Virtual Execution Environments . 33–43 . 10.1145/1254810.1254816 . 978-1-59593-630-1 . . . June 2007 . 12 September 2020.
- Guide . Lantinga . Hilko . Deploying Hardware-Accelerated Graphics with VMware Horizon . . 12 September 2020.
- Web site: visaac. VMware Workstation 16 Pro Release Notes. 2021-03-24. docs.vmware.com. en.
- Guide . Parallels Desktop - User's Guide . Graphics Settings . https://download.parallels.com/desktop/v16/docs/en_US/Parallels%20Desktop%20User's%20Guide/43132.htm . .
- Manual . Hyper-V on Windows Server . Deploy graphics devices using RemoteFX vGPU . https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/deploy/deploy-graphics-devices-using-remotefx-vgpu . . 13 September 2020.
- Manual . Hyper-V on Windows Server . Plan for GPU acceleration in Windows Server . https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/plan/plan-for-gpu-acceleration-in-windows-server . . 15 September 2020.
- Manual . Oracle VM VirtualBox User Manual . Hardware-Accelerated Graphics . https://docs.oracle.com/en/virtualization/virtualbox/6.1/user/guestadd-video.html . . 12 September 2012.
- Manual . Oracle VM VirtualBox User Manual . Guest Additions . https://www.virtualbox.org/manual/ch04.html . . 12 September 2020.
- News: Larabel . Michael . VirtualBox 6.0 3D/OpenGL Performance With VMSVGA Adapter . . 19 December 2018 . 15 September 2020.
- https://www.freerdp.com/2019/02/20/hi-thincast-workstation Hi! - The Thincast Workstation
- Web site: Project . Virgil 3D GPU project . . . 13 September 2020.
- Article . Edge . Jake . Virgil 3D: A virtual GPU. . 10 September 2014 . 13 September 2020.
- News: Wollny . Gert . Virglrenderer and the state of virtualized virtual worlds . Collabora News & Blog . 28 August 2019 . 15 September 2020.
- News: Hoffmann . Gerd . virtio gpu status and plans . 28 November 2019 . 15 September 2020.
- Walters . John . Younge . Andrew . Kang . Dong-In . Yao . Ke-Thia . Kang . Mikyung . Crago . Stephen . Fox . Geoffrey . GPU Passthrough Performance: A Comparison of KVM, Xen, VMware ESXi, and LXC for CUDA and OpenCL Applications . IEEE 7th International Conference on Cloud Computing . . IEEE 7th International Conference on Cloud Computing . 636–643 . 10.1109/CLOUD.2014.90 . 978-1-4799-5063-8 . 2159-6190 . . 2014 . 13 September 2020.
- White paper . GPU Development with Parallels Workstation Extreme . PDF . . 2010 . 13 September 2020.
- Manual . Hyper-V on Windows Server . Deploy graphics devices using Discrete Device Assignment . https://docs.microsoft.com/en-us/windows-server/virtualization/hyper-v/deploy/deploying-graphics-devices-using-dda . . 13 September 2020.
- Manual . XenApp and XenDesktop 7.15 LTSR . HDX 3D Pro . https://docs.citrix.com/en-us/xenapp-and-xendesktop/7-15-ltsr/graphics/hdx-3d-pro.html . . 15 September 2020.
- Manual . Citrix Hypervisor 8.2 . Graphics overview . https://docs.citrix.com/en-us/citrix-hypervisor/graphics.html . . 15 September 2020.
- Guide . GVT-d Setup Guide . . 13 September 2020.
- News: Larabel . Michael . Intel Pushes Their Graphics Virtualization Capabilities . . 4 May 2014 . 13 September 2020.
- Web site: Flyer . Bringing New Use Cases and Workloads to the Cloud with Intel Graphics Virtualization Technology (Intel GVT-g) . . Intel Open Source Technology Center . 2016 . 14 August 2020.
- Web site: Article . Jain . Sunil . Intel Graphics Virtualization Update . . 4 May 2014 . 13 September 2020.
- Web site: Changelog for VirtualBox 6.1 . . . 10 December 2019 . 12 September 2020.
- Web site: PCI passthrough via OVMF - Video card driver virtualization detection. 13 September 2020. Arch Linux Wiki. Wiki.
- Web site: 2021-03-30. GeForce GPU Passthrough for Windows Virtual Machine (Beta). NVIDIA Support.
- Web site: PCI passthrough via OVMF - ArchWiki. 2021-05-20. wiki.archlinux.org.
- Web site: Tian. Lan. 2020-06-25. Intel and NVIDIA GPU Passthrough on a Optimus MUXless Laptop.
- Guide . Virtual GPU Software User Guide . . 13 September 2020.
- White paper . Wong . Tonny . AMD multiuser GPU: hardware-enabled GPU virtualization for a true workstation experience . PDF . . 28 January 2016 . 12 September 2020.
- Wang . Hongbo . 18 October 2018 . 2018-Q3 release of XenGT (Intel GVT-g for Xen) . . 14 August 2020.
- Guide . GVT-g Setup Guide . . 13 September 2020.
- Wang . Hongbo . 18 October 2018 . 2018-Q3 release of KVMGT (Intel GVT-g for KVM) . . 14 August 2020.
- Web site: NVIDIA Virtual GPU Software Supported GPUs . . 9 September 2020.
- Datasheet . AMD FirePro S-Series for Virtualization . PDF . . 2016 . 13 September 2020.
- Web site: Project . Systems/motherboards emulated . PCem . 26 October 2020.
- Manual . VMware Tools Documentation . VMware Tools Device Drivers . https://docs.vmware.com/en/VMware-Tools/10.1.0/com.vmware.vsphere.vmwaretools.doc/GUID-6994A5F9-B62B-4BF1-99D8-E325874A4C7A.html?hWord=N4IghgNiBcIGoFkDuYBOBTABAFQPa4gGdMBlOAcQEEQBfIA . . 12 September 2020.
- Manual . Oracle VM VirtualBox User Manual . Configuring Virtual Machines . https://www.virtualbox.org/manual/ch03.html . . 12 September 2020.
- Manual . QEMU User Documentation . Display options . . 12 September 2020.
- White paper . Long . Simon . Virtual Machine Graphics Acceleration Deployment Guide . PDF . . 2013 . 14 September 2020.
- Manual . XenApp and XenDesktop 7.15 LTSR . OpenGL Software Accelerator . https://docs.citrix.com/en-us/xenapp-and-xendesktop/7-15-ltsr/graphics/opengl-software-accelerator.html . . 15 September 2020.