I'm trying to get this to work. My setup is a Ubuntu 18.04 with two graphic cards, one is onboard, the other one is a NVIDIA GPU. I have a monitor connected and the $DISPLAY is set to :0 My application is to take automated screenshots from webgl-context (BABYLON.js) webpages automatically using puppeteer headless using node-js. The hardware is running in our datacenter and the onboard GPU is physically conntected to a supervision tool that our admins use.
However, regardless of what I do I cannot make puppeteer/chromium build up a context on the nvidia GPU, it seems to only use the the onboard-GPU for everything.
My way of trying this is by running this code:
const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({
headless: true,
args: ['--use-gl=desktop'],
});
const page = await browser.newPage();
await page
.goto('https://codepen.io/BabylonJS/pen/QxzBPd', { waitUntil: 'networkidle0', timeout: 20 * 60 * 1000 })
.catch(e => console.log(e));
await page.screenshot({
path: 'webgl_test.png'
});
await browser.close();
})();
I get a rendered output, however it does not seem to use the nvidia GPU for that as the nvidia-smi which I monitor by using watch -n 0.1 nvidia-smi
did not show any process running.
Is there any way to force puppeteer to use the GPU for rendering the page? Or is it more that I'd have to create a X-Server on this GPU first?