Nvidia GPU Passthrough to Linux virtual machine Ubuntu 20.04 desktop

I’d like to add gpu to linux virtual machine created by LXD. Here is what i did:

  1. Enable iommu, i just add the following to /etc/default/grub:
    GRUB_CMDLINE_LINUX_DEFAULT=“iommu=pt intel_iommu=on rd.driver.blacklist=nouveau”
  2. create lxc profile as stgrabe told(Nvidia GPU Passthrough to Linux Container w/ Ubuntu 20.04 (Full Desktop) - #4 by stgraber):
  • lxc profile create nvidia
  • lxc profile set nvidia nvidia.runtime true
  • lxc profile device add nvidia gpu gpu
  1. Then, i launch ubuntu desktop:
  • lxc launch images:ubuntu/20.04/desktop v1 -p default -p nvidia
    however, when i launch the ubuntu desktop, the teminal got stuck and could not creat the ubuntu desktop virtual machine. And there was no error information, the terminal just show:
  • creating v1
  • starting v1
    and it stuck at the step of starting the container v1.
    Host: Ubuntu 18.04 inteli5 CPU and Nvidia GPU RTX3060.