Run chromium with nvidia GPU and Xvfb on EC2 instance

Cross-posting from stackoverflow (I can’t include the link) since I got no hits there.


I am trying to do hardware accelerated WegGL rendering through puppeteer on an Elastic Beanstalk instance (EC2 running Amazon Linux 2).

My instance is a g4dn.xlarge with Nvidia RTX drivers provided by this AMI.

I’m managing to run chromium with hardware accelerated WebGL but it’s running on the default GPU, not the Nvidia one.

WebGL: Hardware accelerated
WebGL2: Hardware accelerated
Sandboxed: false
GPU0: VENDOR= 0x1d0f, DEVICE=0x1111 *ACTIVE*
GPU1: VENDOR= 0x10de, DEVICE=0x1eb8
Optimus: false

And when I try to follow this post to enable PRIME (I feel like this is what is missing), I fail the xrandr --setprovideroutputsource modesetting NVIDIA-0 step with the message Could not find provider with name modesetting.

How can I make chromium run on the Nvidia GPU?

My config

On start, I run

export DISPLAY=:1
sudo yum install -y xorg-x11-server-Xvfb.x86_64
ps -e |(! grep -q 'Xvfb') && pkill Xvfb
Xvfb :1 -screen 0 1920x1080x24 &

I’m pretty sure I need the X server to run chromium in headful mode because of this bug.
and

sudo amazon-linux-extras install epel -y
sudo yum install -y chromium

My /etc/X11/xorg.conf is

Section "Module"
  Load "modesetting"
EndSection

Section "Device"
  Identifier "nvidia"
  Driver "nvidia"
  BusID "PCI:0:30:0" 
  Option "AllowEmptyInitialConfiguration"
EndSection

Output of lspci:

00:00.0 Host bridge: Intel Corporation 440FX - 82441FX PMC [Natoma]
00:01.0 ISA bridge: Intel Corporation 82371SB PIIX3 ISA [Natoma/Triton II]
00:01.3 Non-VGA unclassified device: Intel Corporation 82371AB/EB/MB PIIX4 ACPI (rev 08)
00:03.0 VGA compatible controller: Amazon.com, Inc. Device 1111
00:04.0 Non-Volatile memory controller: Amazon.com, Inc. Device 8061
00:05.0 Ethernet controller: Amazon.com, Inc. Elastic Network Adapter (ENA)
00:1e.0 3D controller: NVIDIA Corporation TU104GL [Tesla T4] (rev a1)
00:1f.0 Non-Volatile memory controller: Amazon.com, Inc. NVMe SSD Controller

Output of nvidia-settings --glxinfo: ERROR: Unable to load info from any available system

My puppeteer options:

headless: false,
args: [
  '--display=:1',
  '--use-gl=desktop',
  '--disable-gpu-driver-bug-workarounds',
  '--ignore-gpu-blocklist',
]