pimox / pimox7

Proxmox V7 for Raspberry Pi
1.71k stars 156 forks source link

Gpu Passthrough? #115

Open cvocvo opened 1 year ago

cvocvo commented 1 year ago

Is it possible to passthrough the pi’s GPU to a VM? Or otherwise allow a VM to take advantage of hardware acceleration/hardware encoding? I have a VM with Docker running frigate, and frigate has hardware acceleration support for ffmpeg with raspberry pi 3/4. If not it seems the only way to achieve that would be to not use pimox and just run it directly on the hardware.

Thank you!

jiangcuo commented 1 year ago

You can try creating a linux container . https://www.youtube.com/watch?v=-Us8KPOhOCY

cvocvo commented 1 year ago

Ahh yea I’m familiar with passing GPUs, etc through to VMs and LXC. The knowledge gap for me is how to do that for a raspberry pi 4.

The structure is like:

I’m thinking it must be something like some combination of these:

Then it’s essentially: Somehow pass through this from Proxmox (Pi) to LXC (running Docker + Portainer):

/dev/video10
/dev/video11
/dev/video12

And then specify on the Docker container:

--device=/dev/video10:/dev/video10
--device=/dev/video11:/dev/video11
--device=/dev/video12:/dev/video12

Has anyone done this? Is this feasible? Are those device IDs the correct ones? (I’m thinking so if it works for Jellyfin transcoding?)

cvocvo commented 1 year ago

It looks like it does work; hardware acceleration on pi 3's and 4's is currently broken though on Frigate so I will have to find another way to test further.

I edited my container configuration: nano /etc/pve/lxc/500.conf And added the following lines to do the passthrough from the proxmox Pi 4 host to the LXC:

lxc.cgroup2.devices.allow: c 81:* rwm
lxc.mount.entry: /dev/video10 dev/video10 none bind,optional,create=file
lxc.mount.entry: /dev/video11 dev/video11 none bind,optional,create=file
lxc.mount.entry: /dev/video12 dev/video12 none bind,optional,create=file

And then just rebooted the LXC docker container.

Passthrough works to LXC: image

Passthrough works to the Docker Container: image