centricular / gstcefsrc

A simple gstreamer wrapper around Chromium Embedded Framework
83 stars 45 forks source link

cefsrc in headless environment using GPU #76

Closed aiden-jeffrey closed 10 months ago

aiden-jeffrey commented 11 months ago

We're trying to run cefsrc in a headless (no x-server) environment. We've been able to get pipelines to flow using xvfb-run, however that virtual x-server doesn't support GPU pass-through, so for webgl pages, the frame rates are low.

Does anyone have experience running this element in a headless environment?

SteveMcFarlin commented 10 months ago

Yes. I run with a kube deployment. You will need to run X on the host, and then use xserver-xorg-video-dummy in your container (pod). For example if you were using docker on a GCP machine you would run these.

On the host sudo Xorg -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./xserver.log vt1 :1 &

docker run --gpus all -v /usr/local/cuda:/usr/local/cuda --device=/dev/dri/card0 --rm -e DISPLAY=$DISPLAY -v /tmp/X11-unix:/tmp/.X11 -it <image> /bin/bash

In the container Xorg -noreset +extension GLX +extension RANDR +extension RENDER -logfile ./xserver.log vt1 :1 &

Test GPU is enabled GST_PLUGIN_PATH=Release:$GST_PLUGIN_PATH gst-launch-1.0 -e cefsrc url="chrome://gpu" gpu=true chrome-extra-flags="use-gl=egl, enable-gpu-rasterization,ignore-gpu-blocklist" ! video/x-raw, width=1920, height=8080, framerate=1/1 ! cefdemux name=demux ! queue ! videoconvert ! pngenc ! multifilesink location="frame%d.png"

aiden-jeffrey commented 10 months ago

Thank you, this is excellent.

SteveMcFarlin commented 10 months ago

@aiden-jeffrey Your welcome. If you have anymore questions ask them on this thread. I'll try to respond when I can.

MathieuDuponchelle commented 10 months ago

Hey @SteveMcFarlin , can you turn this comment into a README update ? I'm sure that'll be helpful to others :)

SteveMcFarlin commented 10 months ago

@MathieuDuponchelle Sure. Given GPU usage is a machine and X/wayland specific topic I am not sure it should be included in the README. Would a separate GPU.md guidance doc work for you?

MathieuDuponchelle commented 10 months ago

@SteveMcFarlin sure, if you think that makes more sense, please just include a link to that separate file in the main README then.

To be honest for small projects like this one I'll just happily shove everything into a single README :)

SteveMcFarlin commented 9 months ago

Just wanted to follow up on this. I will add a note to the docs, but over the past month or so I have found is not as simple as copy pasta and is very runtime/machine/configuration specific. I guess a few notes to guide someone to a solution is better than nothing though.

MathieuDuponchelle commented 8 months ago

Just wanted to follow up on this. I will add a note to the docs, but over the past month or so I have found is not as simple as copy pasta and is very runtime/machine/configuration specific. I guess a few notes to guide someone to a solution is better than nothing though.

Yes, that would seem useful :)