0650.html 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. <!DOCTYPE html>
  2. <html lang="en" xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <title>Passing a GPU to a Proxmox VM with PCI Passthrough</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  6. <meta charset="UTF-8">
  7. <meta name="keywords" content="Proxmox Video Card Passthrough,GPU Pass Through,GPU Passthrough,Proxmox VE,Hypervisor,Virtual Machine,VM,GPU,Graphics Card,PCI,PCIe,Passthrough,Proxmox,Linux,Debian,Windows,How To,Tutorial,i12bretro">
  8. <meta name="author" content="i12bretro">
  9. <meta name="description" content="Passing a GPU to a Proxmox VM with PCI Passthrough">
  10. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  11. <link rel="icon" type="image/x-icon" href="includes/favicon.ico">
  12. <script type="text/javascript" src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
  13. <script type="text/javascript" src="includes/js/steps.js"></script>
  14. <link href="css/steps.css" rel="stylesheet" type="text/css" />
  15. </head>
  16. <body>
  17. <div id="gridContainer">
  18. <div class="topMargin"></div>
  19. <div id="listName" class="topMargin">
  20. <h1>Passing a GPU to a Proxmox VM with PCI Passthrough</h1>
  21. </div>
  22. <div></div>
  23. <div id="content">
  24. <h2>Enabling PCI Passthrough</h2>
  25. <ol>
  26. <li>Log into ProxMox VE either via SSH or the web based shell</li>
  27. <li>Run the following commands
  28. <div class="codeBlock"># edit grub configuration to enable IOMMU<br />
  29. nano /etc/default/grub</div>
  30. </li>
  31. <li>Press CTRL+W and search for GRUB_CMDLINE_LINUX_DEFAULT=</li>
  32. <li>Add the following value to GRUB_CMDLINE_LINUX_DEFAULT
  33. <ol start="1" style="list-style-type: lower-alpha;">
  34. <li>If running an Intel CPU, intel_iommu=on
  35. <p>GRUB_CMDLINE_LINUX_DEFAULT=&quot;quiet intel_iommu=on&quot;</p>
  36. </li>
  37. <li>If running an AMD CPU, amd_iommu=on
  38. <p>GRUB_CMDLINE_LINUX_DEFAULT=&quot;quiet amd_iommu=on&quot;</p>
  39. </li>
  40. </ol>
  41. </li>
  42. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  43. <li>Continue with the following commands
  44. <div class="codeBlock"># update grub with config change<br />
  45. update-grub<br />
  46. # add vfio modules<br />
  47. nano /etc/modules</div>
  48. </li>
  49. <li>Add the following to the bottom of the file
  50. <p>vfio<br />
  51. vfio_iommu_type1<br />
  52. vfio_pci<br />
  53. vfio_virqfd</p>
  54. </li>
  55. <li>Press CTRL+O, Enter, CTRL+X to write the changes</li>
  56. <li>Continue with the following commands
  57. <div class="codeBlock"># IOMMU interrupt mapping<br />
  58. echo &quot;options vfio_iommu_type1 allow_unsafe_interrupts=1&quot; &gt; /etc/modprobe.d/iommu_unsafe_interrupts.conf<br />
  59. echo &quot;options kvm ignore_msrs=1&quot; &gt; /etc/modprobe.d/kvm.conf<br />
  60. # blacklist drivers<br />
  61. echo &quot;blacklist radeon&quot; &gt;&gt; /etc/modprobe.d/blacklist.conf<br />
  62. echo &quot;blacklist nouveau&quot; &gt;&gt; /etc/modprobe.d/blacklist.conf<br />
  63. echo &quot;blacklist nvidia&quot; &gt;&gt; /etc/modprobe.d/blacklist.conf<br />
  64. # list pci devices<br />
  65. lspci -v</div>
  66. </li>
  67. <li>Scroll through the output and find the GPU (usually a video and audio device associated with it) and make note of the device identifier (ex 01:00.0, 01:00.1)</li>
  68. <li>Continue with the following commands
  69. <div class="codeBlock"># output the vendor ID(s) of the devices<br />
  70. # replace the device identifier (01:00) as needed<br />
  71. lspci -n -s 01:00</div>
  72. </li>
  73. <li>Make note of the vendor ID(s) output in the format abcd:1234</li>
  74. <li>Continue with the following commands
  75. <div class="codeBlock"># replace the vendor ids from the output of the previous step as needed<br />
  76. echo &quot;options vfio-pci ids=1002:6611,1002:aab0 disable_vga=1&quot;&gt; /etc/modprobe.d/vfio.conf<br />
  77. # update initramfs<br />
  78. update-initramfs -u<br />
  79. # reboot proxmox host<br />
  80. reboot now</div>
  81. </li>
  82. </ol>
  83. <h2>Passing GPU to A VM</h2>
  84. <ol>
  85. <li>Log into the ProxMox web UI</li>
  86. <li>Expand the target node and select the target VM from the left navigation menu</li>
  87. <li>Select Hardware from the left sub-navigation menu</li>
  88. <li>Click Add &gt; PCI Device</li>
  89. <li>Select the GPU from the listing<br />
  90. <span style="font-size:14px;"><em>NOTE: I have found that there is some trial and error required to get the GPU to work properly depending on the guest operating system. If you find that the GPU isn&#39;t working with all options checked, stop the VM, and edit the PCI hardware, unchecking one option at a time to see if you can find a working combination</em></span></li>
  91. <li>Select Display &gt; Set the dropdown to none (none) &gt; Click OK</li>
  92. <li>If you intend to use the VM at the console (not via RDP or VNC), you will need to passthrough a USB keyboard and mouse by clicking Add &gt; USB Device &gt; Select the USB device(s) or port(s) to pass to the VM</li>
  93. <li>Click Start at the top right of the page</li>
  94. <li>Watch the output of the GPU on an external display<br />
  95. <span style="font-size:14px;"><em>If there is no output from the GPU, stop the VM and adjust the PCI hardware options as noted above</em></span></li>
  96. <li>Once the VM has booted and is outputting to the GPU, install drivers for the GPU as necessary</li>
  97. </ol>
  98. <p>Source: <a href="https://www.reddit.com/r/homelab/comments/b5xpua/the_ultimate_beginners_guide_to_gpu_passthrough/" target="_blank">https://www.reddit.com/r/homelab/comments/b5xpua/the_ultimate_beginners_guide_to_gpu_passthrough/</a><br />
  99. Documentation: <a href="https://pve.proxmox.com/wiki/Pci_passthrough" target="_blank">https://pve.proxmox.com/wiki/Pci_passthrough</a></p>
  100. </div>
  101. </div>
  102. </body>
  103. </html>