stephanlensky / zendriver-docker

Undetectable browser automation in Docker using Python/Zendriver. Full VNC debugging support.
https://slensky.com/zendriver/
GNU Affero General Public License v3.0
5 stars 1 forks source link

Add Nvidia GPU support #3

Open dmarts05 opened 6 days ago

dmarts05 commented 6 days ago

Hi, I have been trying to make this work with my Nvidia GPU but it seems to be harder than I thought.

I am using an RTX 2070 with Arch Linux as my host machine and this is the error that it gives at first: 00:00:00.003 [ERROR] [sway/main.c:65] Proprietary Nvidia drivers are NOT supported. Use Nouveau. To launch sway anyway, launch with --unsupported-gpu and DO NOT report issues.

After adding that flag to entrypoint_user.sh it throws another error: app-1 | 00:00:00.001 [ERROR] [sway/main.c:62] !!! Proprietary Nvidia drivers are in use !!! app-1 | libEGL warning: egl: failed to create dri2 screen app-1 | 00:00:00.014 [ERROR] [wlr] [EGL] command: eglInitialize, error: EGL_NOT_INITIALIZED (0x3001), message: "DRI2: failed to create screen" app-1 | libEGL warning: egl: failed to create dri2 screen app-1 | 00:00:00.017 [ERROR] [wlr] [EGL] command: eglInitialize, error: EGL_NOT_INITIALIZED (0x3001), message: "DRI2: failed to create screen" app-1 | libEGL warning: failed to open /dev/dri/card1: Permission denied app-1 | app-1 | 00:00:00.017 [ERROR] [wlr] [EGL] command: eglInitialize, error: EGL_NOT_INITIALIZED (0x3001), message: "DRI2: failed to load driver" app-1 | 00:00:00.017 [ERROR] [wlr] [EGL] command: eglInitialize, error: EGL_NOT_INITIALIZED (0x3001), message: "eglInitialize" app-1 | 00:00:00.017 [ERROR] [wlr] [render/egl.c:269] Failed to initialize EGL app-1 | 00:00:00.017 [ERROR] [wlr] [render/egl.c:572] Failed to initialize EGL context app-1 | 00:00:00.017 [ERROR] [wlr] [render/gles2/renderer.c:804] Could not initialize EGL

Any help would be appreciated, thanks!

stephanlensky commented 3 days ago

Hey @dmarts05, I don't currently have an Nvidia linux box to test, but this

libEGL warning: failed to open /dev/dri/card1: Permission denied

looks a lot like an error I saw on my AMD machine when the Docker user didn't have permission to access /dev/dri/renderD128.

In my case, this file was owned by the render group (gid 107) and thus I was able to resolve the issue by assigning the Docker user a group with that same gid (107). This is what the RENDER_GROUP_GID environment variable is for (see First Time Setup).

Now, it looks like on your system, instead of (or maybe in addition to?) using the /dev/dri/renderDXXX device, EGL is trying to directly access the /dev/dri/card1 device.

Here's what I would suggest:

  1. Figure out what group owns /dev/dri/card1 on your host (probably it's the video group):
    stat /dev/dri/card1 -c "%G %g"
  2. Set the RENDER_GROUP_GID environment variable in your Docker container to the gid of the group found in the previous step.

There are probably two outcomes after doing this:

  1. Everything works 🥳 - this means that on Nvidia systems, you need to give the Docker user permission for /dev/dri/cardX, NOT /dev/dri/renderDXXX
  2. You get another permissions error about /dev/dri/renderDXXX. This indicates that on Nvidia systems, the Docker user needs both the render AND video groups. To fix this, we'll need to adjust the Docker image to allow setting GIDs for both of these groups instead of just the render group.
stephanlensky commented 3 days ago

It looks like Nvidia also has some dedicated tools to more easily support using GPUs in Docker containers, but I don't have experience with it. It might be worth looking into though: https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/index.html

dmarts05 commented 1 day ago

Hi, thanks for all the support! I'll try this out during the weekend :)