I’d like to run puppeteer with gpu acceleration for a webgl rendering system.
I’ve tried a few configurations but nothing seems to work.
Doing some research on this topic and it looks like it’s not an easy task.
So far, I’ve tried with this dockerfile, which I know, it’s absolutely not optimized. It’s a dev purpose for now.
I’ve used the ubuntu:22.04 image as mentionned in the documentation.
The following instruction keeps failing, it’s why it’s a comment.
RUN nvidia-smi
FROM ubuntu:22.04 AS base
RUN apt update -q && apt install -y ca-certificates wget && \
wget -qO /cuda-keyring.deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb && \
dpkg -i /cuda-keyring.deb && apt update -q
FROM base AS builder
RUN apt install -y --no-install-recommends git cuda-nvcc-12-2
RUN git clone --depth=1 https://github.com/nvidia/cuda-samples.git /cuda-samples
RUN cd /cuda-samples/Samples/1_Utilities/deviceQuery && \
make && install -m 755 deviceQuery /usr/local/bin
FROM base AS runtime
RUN apt install -y --no-install-recommends libcudnn8 libcublas-12-2
RUN apt-get update && apt-get install -y \
wget \
ca-certificates \
python3-pip \
python3-venv \
ffmpeg \
libglib2.0-0 \
libnss3 \
libgconf-2-4 \
libfontconfig1 \
libxss1 \
libxrandr2 \
libasound2 \
libatk1.0-0 \
libatk-bridge2.0-0 \
libgtk-3-0 \
gnupg
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - && \
sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" > /etc/apt/sources.list.d/google-chrome.list'
RUN apt-get update && apt-get install -y google-chrome-stable
#RUN nvidia-smi
COPY requirements.txt .
RUN python3 -m venv /opt/venv
ENV PATH="/opt/venv/bin:$PATH"
RUN pip install --no-cache-dir -r requirements.txt
COPY . /app
WORKDIR /app
ENV PORT=8080
CMD ["python3", "main.py"]
I use google-chrome stable because I’ve readed it’s more likely to be compiled with gpu drivers or so.
Here’s my puppeteer flags:
"--no-sandbox",
"--enable-webgl",
"--enable-gpu",
"--enable-accelerated-2d-canvas",
"--enable-gpu-rasterization",
"--use-gl=desktop",
"--use-vulkan",
"--enable-zero-copy",
"--enable-features=VaapiVideoDecoder,WebRTC-H264WithOpenH264FFmpeg,SharedArrayBuffer",
"--ignore-gpu-blocklist",
"--ozone-platform=headless",
"--disable-dev-shm-usage",
and here’s my fly.toml:
app = 'drawnshow-renderer'
primary_region = 'ord'
[build]
dockerfile = 'Dockerfile'
[env]
PORT = '8080'
PYTHONUNBUFFERED = '1'
[[services]]
protocol = 'tcp'
internal_port = 8080
[[services.ports]]
port = 80
handlers = ['http']
[[services.ports]]
port = 443
handlers = ['tls', 'http']
[[services]]
protocol = 'udp'
internal_port = 3478
auto_start_machines = false
ports = []
[[vm]]
gpus = 1
gpu_kind = 'a10'
memory = '8gb'
cpu_kind = 'performance'
cpus = 4
[deploy]
strategy = "immediate"
max_unavailable = 0
If you could help me with this, I’ll be very happy to create a minimal repo to add in this list: