{"id":9635,"date":"2025-07-22T06:28:58","date_gmt":"2025-07-22T06:28:58","guid":{"rendered":"https:\/\/www.gpu4host.com\/knowledge-base\/?p=9635"},"modified":"2025-07-22T06:29:01","modified_gmt":"2025-07-22T06:29:01","slug":"kvm-gpu-setup","status":"publish","type":"post","link":"https:\/\/www.gpu4host.com\/knowledge-base\/kvm-gpu-setup\/","title":{"rendered":"KVM GPU setup"},"content":{"rendered":"<div class='epvc-post-count'><span class='epvc-eye'><\/span>  <span class=\"epvc-count\"> 964<\/span><span class='epvc-label'> Views<\/span><\/div>\n<h2 class=\"wp-block-heading\"><strong>KVM GPU Setup for NVIDIA GPUs: Passthrough &amp; Display on Host<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Virtualization helps all users to enhance their hardware by running many virtual machines (VMs) together on a single physical host. For AI-based tasks, modern gaming, or GPU-heavy apps such as an AI image generator, having GPU access inside a virtual machine is very important. This is the case where a KVM GPU setup utilizing passthrough in QEMU\/KVM stands out.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">In this comprehensive knowledge base, we\u2019ll just take you through how to configure a KVM GPU setup, especially for passthrough, and make the guest GPU output displayed on your host display. Even if you are utilizing an NVIDIA A100, a GPU dedicated server, or a GPU cluster from GPU4HOST, this whole guide is customized to help you get GPU passthrough working successfully.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>What is GPU Passthrough?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">GPU passthrough basically is a method that helps a virtual machine to directly utilize a physical GPU by passing it from the host system. The VM gets complete GPU access, making it a perfect option for performance-intensive workloads such as:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>ML and AI GPU workloads<\/li>\n\n\n\n<li>3D graphics rendering<\/li>\n\n\n\n<li>Modern gaming<\/li>\n\n\n\n<li>Video editing<\/li>\n\n\n\n<li>Running an <a href=\"https:\/\/www.gpu4host.com\/ai-image-generator\">AI image generator<\/a><\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Prerequisites for KVM GPU Setup<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Before deeply diving into the KVM GPU setup, make sure that you have the following:<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Hardware Needs:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A CPU along with VT-d (Intel) or AMD-Vi (AMD) support<\/li>\n\n\n\n<li>A discrete GPU proficient in passthrough (NVIDIA or AMD)<\/li>\n\n\n\n<li>UEFI BIOS simply with IOMMU and virtualization enabled<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Software Needs:<\/strong><\/h3>\n\n\n\n<ul class=\"wp-block-list\">\n<li>A Linux host, along with KVM\/QEMU installed (Fedora\/Ubuntu\/Arch preferred).<\/li>\n\n\n\n<li>virt-manager for GUI setup (optional).<\/li>\n\n\n\n<li>A secondary GPU for the host if you are passing through the main one.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Step-by-Step KVM GPU Setup<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"768\" height=\"288\" src=\"https:\/\/www.gpu4host.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Step-by-Step-KVM-GPU-Setup-1.webp\" alt=\"KVM GPU setup\" class=\"wp-image-9637\" srcset=\"https:\/\/www.gpu4host.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Step-by-Step-KVM-GPU-Setup-1.webp 768w, https:\/\/www.gpu4host.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Step-by-Step-KVM-GPU-Setup-1-300x113.webp 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Let\u2019s just break down the KVM GPU setup procedure into fully manageable steps.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 1: Check Virtualization Support<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Run the below-mentioned command to check for virtualization add-ons:<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-8522b0e5aa3668143978f30bcc173799 wp-block-paragraph\" style=\"color:#41b100\">egrep -c &#8216;(vmx|svm)&#8217; \/proc\/cpuinfo<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">You should also see a value that is more than 0.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Allow IOMMU in the GRUB setup:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For AMD:<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-3f462b14b82f886c3f41af8af7d3adaf wp-block-paragraph\" style=\"color:#41b100\">GRUB_CMDLINE_LINUX_DEFAULT=&#8221;quiet amd_iommu=on&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For Intel:<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-24316b57912b5fbd33226748e5bd6e21 wp-block-paragraph\" style=\"color:#41b100\">GRUB_CMDLINE_LINUX_DEFAULT=&#8221;quiet intel_iommu=on&#8221;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Just update GRUB &amp; reboot:<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-4597d4107df4a8c496d8d8772459f42f wp-block-paragraph\" style=\"color:#41b100\">sudo update-grub<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-2f7d0cf30b6eb5ba451a366d0430308e wp-block-paragraph\" style=\"color:#41b100\">sudo reboot<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 2: Check GPU Devices<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Identify your GPU and its related IOMMU group:<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-4f3ddc87f8123c60f30a5621a912dd0f wp-block-paragraph\" style=\"color:#41b100\">lspci -nnk | grep -iA2 VGA<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Note the PCI IDs of the GPU and related HDMI\/audio devices.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>&nbsp;Step 3: Isolate the GPU<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Utilize vfio-pci to bind the GPU to the VM. Include the GPU PCI IDs in\/etc\/modprobe.d\/vfio.conf:<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-aac728cbdb7e967ae6255b48020220e0 wp-block-paragraph\" style=\"color:#41b100\">options vfio-pci ids=10de:1db6,10de:10f0<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Simply replace the IDs with those of your GPU.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Include in \/etc\/modules:<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-b9b82239a3c55b5ba8bafda85c19fc2e wp-block-paragraph\" style=\"color:#41b100\">vfio<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-f2f859ca8a384755499f865f57a59525 wp-block-paragraph\" style=\"color:#41b100\">vfio_iommu_type1<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-55345b49cf35e3cb93301666a6a29f2d wp-block-paragraph\" style=\"color:#41b100\">vfio_pci<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-18c860840a0f8fe02e81cd177877b35c wp-block-paragraph\" style=\"color:#41b100\">vfio_virqfd<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Update initramfs &amp; then reboot:<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-3f592e02f3b2488f6469b24448c27897 wp-block-paragraph\" style=\"color:#41b100\">sudo update-initramfs -u<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-2f7d0cf30b6eb5ba451a366d0430308e wp-block-paragraph\" style=\"color:#41b100\">sudo reboot<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This fully prepares your KVM GPU setup for passthrough.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 4: Create the Virtual Machine<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You can easily utilize virt-manager or virsh.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>With the help of <\/strong><strong>virt-manager<\/strong><strong>:<\/strong><\/h4>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open virt-manager<\/li>\n\n\n\n<li>Create a new VM<\/li>\n\n\n\n<li>Select the \u201cCustom Configuration\u201d option.<\/li>\n\n\n\n<li>Set UEFI firmware (OVMF)<\/li>\n\n\n\n<li>Include PCI Host Device\u2014choose your GPU and its audio device.<\/li>\n<\/ol>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>With the help of QEMU (CLI):<\/strong><\/h4>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-e31a8a72ecf1aebb3789a49357769f54 wp-block-paragraph\" style=\"color:#41b100\">qemu-system-x86_64 \\<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-ae0f15219b0195dbeff997bc3742a2a1 wp-block-paragraph\" style=\"color:#41b100\">-enable-kvm \\<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-4bad378bef795bc77c82901f261bbcc3 wp-block-paragraph\" style=\"color:#41b100\">-cpu host,kvm=off \\<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-0e0eba1001ca652fd3e2a8f2fa1ef4bb wp-block-paragraph\" style=\"color:#41b100\">-m 8192 \\<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-dc1236e76602f87fab43584f4e8ef939 wp-block-paragraph\" style=\"color:#41b100\">-device vfio-pci,host=01:00.0 \\<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-861a4a63f9ab57dc522093c20c225dd8 wp-block-paragraph\" style=\"color:#41b100\">&#8230;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Replace 01:00.0 simply with your PCI address of the GPU.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 5: Display GPU Result on Host<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">You have two well-known options to display the GPU result on the host:<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Option 1: Pass the monitor directly<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Link your monitor to the passed-through GPU. Once the virtual machine boots, it will take over the whole display.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\"><strong>Option 2: Utilize Looking Glass (Advanced)<\/strong><\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">Opting Glass helps share the GPU&#8217;s result back to the host in a specific window.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Needs a shared memory buffer between both the guest and host.<\/li>\n\n\n\n<li>Install the client on the host and the service in the guest.<\/li>\n\n\n\n<li>Perfect for GPU hosting situations where remote access is required.<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\"><strong>Step 6: Test the virtual machine with GPU Passthrough<\/strong><\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Install all GPU drivers required inside the VM (Linux or Windows). Check if the GPU is found.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For Windows:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Install NVIDIA\/AMD drivers<\/li>\n\n\n\n<li>Verify Device Manager<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">For Linux:<\/p>\n\n\n\n<p class=\"has-text-color has-link-color wp-elements-09164d8aa0b807a3366c3e34057e3792 wp-block-paragraph\" style=\"color:#41b100\">nvidia-smi<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If your KVM GPU setup is appropriate, your VM should now have complete admin access to the passed-through GPU.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Real-World Use Cases for KVM GPU Setup<\/strong><\/h2>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"768\" height=\"288\" src=\"https:\/\/www.gpu4host.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Real-World-Use-Cases-for-KVM-GPU-Setup-1.webp\" alt=\"KVM GPU setup\" class=\"wp-image-9638\" srcset=\"https:\/\/www.gpu4host.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Real-World-Use-Cases-for-KVM-GPU-Setup-1.webp 768w, https:\/\/www.gpu4host.com\/knowledge-base\/wp-content\/uploads\/2025\/07\/Real-World-Use-Cases-for-KVM-GPU-Setup-1-300x113.webp 300w\" sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/figure>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>AI Model Training<\/strong>: Run PyTorch or TensorFlow on a VM simply with <a href=\"https:\/\/www.gpu4host.com\/nvidia-v100-hosting\">NVIDIA V100<\/a> or a similar type of GPU.<\/li>\n\n\n\n<li><strong>AI Image Generator<\/strong>: Pass through the GPU to create images in seconds.<\/li>\n\n\n\n<li><strong>GPU Server Hosting<\/strong>: Let clients isolate GPU access with the help of VMs.<\/li>\n\n\n\n<li><strong>GPU Clusters<\/strong>: Create flexible GPU-based VMs in a <a href=\"https:\/\/www.gpu4host.com\/gpu-cluster\">GPU cluster<\/a> environment.<\/li>\n\n\n\n<li><strong>Remote Desktop<\/strong>: High-end remote desktops for creators and developers.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Security Considerations<\/strong><\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Utilize a dedicated GPU for passthrough to prevent host issues.<\/li>\n\n\n\n<li>Enable virtio and vfio security to sandbox the virtual machine.<\/li>\n\n\n\n<li>Limit all user access on multi-tenant GPU hosting environments.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Why GPU4HOST for KVM GPU Setup?<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">GPU4HOST offers a cutting-edge GPU server, consisting of:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GPU dedicated server options with complete passthrough support<\/li>\n\n\n\n<li>Pre-setup KVM environments<\/li>\n\n\n\n<li>Quick access to <a href=\"https:\/\/www.gpu4host.com\/nvidia-a100-rental\">NVIDIA A100<\/a>, V100, and a lot more<\/li>\n\n\n\n<li>Flexible GPU hosting, along with cluster support<\/li>\n\n\n\n<li>24\/7 expert support for advanced use cases such as AI model training and image generation<\/li>\n<\/ul>\n\n\n\n<p class=\"wp-block-paragraph\">With the help of GPU4HOST, setting up and running your KVM GPU setup is a lot easier, quicker, and highly enhanced.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\"><strong>Final Thoughts<\/strong><\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Learning about KVM GPU setup, especially for passthrough in QEMU, is a complete game-changer\u2014even if you are building a GPU-based VM for AI-powered tasks, modern gaming, or an <a href=\"https:\/\/www.infinitivehost.com\/gpu-dedicated-server\" target=\"_blank\" rel=\"noopener\">AI image generator<\/a>. This whole process, while a technical part, gives you exceptional control over hardware virtualization.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Ranging from setting up IOMMU to choosing the appropriate PCI device and handling display results, every single step helps you get the complete potential of your <a href=\"https:\/\/www.gpu4host.com\/\">GPU server<\/a>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If you are opting for smooth deployment, high-end AI GPU proficiencies, or cluster-ready infrastructure, GPU4HOST is your go-to platform.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>964 Views KVM GPU Setup for NVIDIA GPUs: Passthrough &amp; Display on Host Virtualization helps all users to enhance their hardware by running many virtual machines (VMs) together on a single physical host. For AI-based tasks, modern gaming, or GPU-heavy apps such as an AI image generator, having GPU access inside a virtual machine is [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":9636,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"inline_featured_image":false,"footnotes":""},"categories":[1],"tags":[],"class_list":["post-9635","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web-hosting"],"_links":{"self":[{"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9635","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/comments?post=9635"}],"version-history":[{"count":1,"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9635\/revisions"}],"predecessor-version":[{"id":9639,"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/posts\/9635\/revisions\/9639"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/media\/9636"}],"wp:attachment":[{"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/media?parent=9635"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/categories?post=9635"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gpu4host.com\/knowledge-base\/wp-json\/wp\/v2\/tags?post=9635"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}