I'm confused by this scenario. Using the Google Cloud provided ssh shell I run my code and Puppeteer seems to not be able to recognize the GPU.
When I run the same code on the remote desktop (https://remotedesktop.google.com/headless), the chrome instance has access to the GPU.
In GCP SSH console (before remote desktop is added) I run
sudo apt update
sudo apt install --assume-yes wget tasksel
[[ $(/usr/bin/lsb_release --codename --short) == "stretch" ]] && sudo apt install --assume-yes libgbm1/stretch-backports
wget https://dl.google.com/linux/direct/chrome-remote-desktop_current_amd64.deb
sudo apt-get install --assume-yes ./chrome-remote-desktop_current_amd64.deb
sudo DEBIAN_FRONTEND=noninteractive apt install --assume-yes xfce4 desktop-base dbus-x11 xscreensaver
sudo bash -c 'echo "exec /etc/X11/Xsession /usr/bin/xfce4-session" > /etc/chrome-remote-desktop-session'
I head over to the remote desktop to grab the DISPLAY code (something like)
DISPLAY= /opt/google/chrome-remote-desktop/start-host --code="4/0AX4XfWjjF3_FZ9VPbhcT9Va4OdV_k1FSQsTV_saHRmSyBnhY1JRAM9Rx5xVeg2WjDkvJsA" --redirect-url="https://remotedesktop.google.com/_/oauthredirect" --name=$(hostname)
When I try to run it inside the normal shell I get tons of errors
index > { logger: { initFrame: 1656118667259 } } │
│[ 1] index Mem: 86 MB ││ index > { logger: { initMedia: 1656118667259 } } │
│[ 2] index Mem: 86 MB ││ index > { logger: { finishMedia: 1656118667259 } } │
│[ 3] index Mem: 82 MB ││ index > { logger: '+++++++++++++++++++++++++' } │
│[ 4] index Mem: 113 MB ││ index > { logger: { initFrame: 1656118667277 } } │
│[ 5] index Mem: 68 MB ││ index > [0625/005747.311634:ERROR:gl_context.cc(109)] Failed to make │
│[ 6] index Mem: 68 MB ││ index > [0625/005747.311727:ERROR:gl_surface_egl.cc(822)] EGL Driver │
│[ 7] index Mem: 68 MB ││ index > [0625/005747.311755:ERROR:gl_context_egl.cc(365)] eglCreateConte │
│[ 8] index Mem: 68 MB ││ index > [0625/005747.311767:ERROR:gpu_channel_manager.cc(832)] │
│[ 9] index Mem: 68 MB ││ index > [0625/005747.311779:ERROR:shared_image_stub.cc(537)] SharedImage │
│[10] index Mem: 68 MB ││ index > [0625/005747.311795:ERROR:gpu_channel.cc(607)] GpuChannel: │
│[11] index Mem: 68 MB ││ index > [0625/005747.312512:ERROR:gl_context.cc(109)] Failed to make │
│[12] index Mem: 68 MB ││ index > [0625/005747.312586:ERROR:gl_surface_egl.cc(822)] EGL Driver │
│[13] index Mem: 68 MB ││ index > [0625/005747.312611:ERROR:gl_context_egl.cc(365)] eglCreateConte │
│[14] index Mem: 69 MB ││ index > [0625/005747.312626:ERROR:gpu_channel_manager.cc(832)] │
│[15] index Mem: 68 MB ││ index > [0625/005747.312644:ERROR:shared_image_stub.cc(537)] SharedImage │
│ ││ index > [0625/005747.312659:ERROR:gpu_channel.cc(607)] GpuChannel: │
│ ││ index > [0625/005747.313372:ERROR:gl_context.cc(109)] Failed to make │
│ ││ index > [0625/005747.313437:ERROR:gl_surface_egl.cc(822)] EGL Driver │
│ ││ index > [0625/005747.313450:ERROR:gl_context_egl.cc(365)] eglCreateConte │
│ ││ index > [0625/005747.313460:ERROR:gpu_channel_manager.cc(832)] │
│ ││ index > [0625/005747.313470:ERROR:shared_image_stub.cc(537)] SharedImage │
│ ││ index > [0625/005747.313477:ERROR:gpu_channel.cc(607)] GpuChannel: │
│ ││ index > [0625/005747.315133:INFO:CONSOLE(9261)] "Error: no-webgl-context │
│ ││ index > { logger: { mount: '12:57:47 AM' } }
I kill all the processes via that shell. Then run the same command on the remote instance, within the GUI I open the terminal and run the same command.
Within the remote desktop shell things work great and GPU is clearly working.
Here are some more logs -- I think EGLDisplay missing is an interesting clue
┌─ Process List ───────────────────────────────────────────────────────┐┌── index Logs ──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────┐
│[ 0] index Mem: 85 MB CPU: 0 % online ││ index > [0625/010807.680756:ERROR:gl_context.cc(109)] Failed to make current since context is marked as lost │
│[ 1] index Mem: 86 MB CPU: 0 % online ││ index > [0625/010807.680855:ERROR:gl_surface_egl.cc(822)] EGL Driver message (Error) eglCreateContext: EGL_NOT_INITIALIZED error: In eglCreateContext: EGLDisplay │
│[ 2] index Mem: 86 MB CPU: 0 % online ││ index > [0625/010807.680887:ERROR:gl_context_egl.cc(365)] eglCreateContext failed with error EGL_SUCCESS │
│[ 3] index Mem: 85 MB CPU: 0 % online ││ index > [0625/010807.680910:ERROR:gpu_channel_manager.cc(832)] ContextResult::kFatalFailure: Failed to create shared context for virtualization. │
│[ 4] index Mem: 68 MB CPU: 0 % online ││ index > [0625/010807.680927:ERROR:shared_image_stub.cc(537)] SharedImageStub: unable to create context │
│[ 5] index Mem: 114 MB CPU: 14 % online ││ index > [0625/010807.680961:ERROR:gpu_channel.cc(607)] GpuChannel: Failed to create SharedImageStub │
│[ 6] index Mem: 69 MB CPU: 0 % online ││ index > [0625/010807.681559:ERROR:gl_context.cc(109)] Failed to make current since context is marked as lost │
│[ 7] index Mem: 68 MB CPU: 0 % online ││ index > [0625/010807.681637:ERROR:gl_surface_egl.cc(822)] EGL Driver message (Error) eglCreateContext: EGL_NOT_INITIALIZED error: In eglCreateContext: EGLDisplay │
│[ 8] index Mem: 68 MB CPU: 0 % online ││ index > [0625/010807.681693:ERROR:gl_context_egl.cc(365)] eglCreateContext failed with error EGL_SUCCESS │
│[ 9] index Mem: 68 MB CPU: 0 % online ││ index > [0625/010807.681719:ERROR:gpu_channel_manager.cc(832)] ContextResult::kFatalFailure: Failed to create shared context for virtualization. │
│[10] index Mem: 68 MB CPU: 0 % online ││ index > [0625/010807.681732:ERROR:shared_image_stub.cc(537)] SharedImageStub: unable to create context │
│[11] index Mem: 68 MB CPU: 0 % online ││ index > [0625/010807.681744:ERROR:gpu_channel.cc(607)] GpuChannel: Failed to create SharedImageStub │
│[12] index Mem: 68 MB CPU: 0 % online ││ index > [0625/010807.695351:INFO:CONSOLE(80057)] "It looks like there are several instances of 'styled-components' initialized in this application. This may cause │
│[13] index Mem: 68 MB CPU: 0 % online ││ index > See https://s-c.sh/2BAXzed for more info.", source: (80057) │
│[14] index Mem: 68 MB CPU: 0 % online ││ index > { logger: '+++++++++++++++++++++++++' } │
│[15] index Mem: 68 MB CPU: 0 % online ││ index > { logger: { initFrame: 1656119287703 } } │
│ ││ index > { logger: { initMedia: 1656119287703 } } │
│ ││ index > { logger: { finishMedia: 1656119287703 } } │
│ ││ index > { logger: '+++++++++++++++++++++++++' } │
│ ││ index > { logger: { initFrame: 1656119287720 } } │
│ ││ index > [0625/010807.753002:ERROR:gl_context.cc(109)] Failed to make current since context is marked as lost │
│ ││ index > [0625/010807.753070:ERROR:gl_surface_egl.cc(822)] EGL Driver message (Error) eglCreateContext: EGL_NOT_INITIALIZED error: In eglCreateContext: EGLDisplay │
│ ││ index > [0625/010807.753107:ERROR:gl_context_egl.cc(365)] eglCreateContext failed with error EGL_SUCCESS │
│ ││ index > [0625/010807.753117:ERROR:gpu_channel_manager.cc(832)] ContextResult::kFatalFailure: Failed to create shared context for virtualization. │
│ ││ index > [0625/010807.753128:ERROR:shared_image_stub.cc(537)] SharedImageStub: unable to create context │
│ ││ index > [0625/010807.753150:ERROR:gpu_channel.cc(607)] GpuChannel: Failed to create SharedImageStub │
│ ││ index > [0625/010807.753858:ERROR:gl_context.cc(109)] Failed to make current since context is marked as lost │
│ ││ index > [0625/010807.753924:ERROR:gl_surface_egl.cc(822)] EGL Driver message (Error) eglCreateContext: EGL_NOT_INITIALIZED error: In eglCreateContext: EGLDisplay │
│ ││ index > [0625/010807.753949:ERROR:gl_context_egl.cc(365)] eglCreateContext failed with error EGL_SUCCESS │
│ ││ index > [0625/010807.753961:ERROR:gpu_channel_manager.cc(832)] ContextResult::kFatalFailure: Failed to create shared context for virtualization. │
│ ││ index > [0625/010807.753974:ERROR:shared_image_stub.cc(537)] SharedImageStub: unable to create context │
│ ││ index > [0625/010807.753995:ERROR:gpu_channel.cc(607)] GpuChannel: Failed to create SharedImageStub │
│ ││ index > [0625/010807.754707:ERROR:gl_context.cc(109)] Failed to make current since context is marked as lost │
│ ││ index > [0625/010807.754767:ERROR:gl_surface_egl.cc(822)] EGL Driver message (Error) eglCreateContext: EGL_NOT_INITIALIZED error: In eglCreateContext: EGLDisplay │
│ ││ index > [0625/010807.754781:ERROR:gl_context_egl.cc(365)] eglCreateContext failed with error EGL_SUCCESS │
│ ││ index > [0625/010807.754791:ERROR:gpu_channel_manager.cc(832)] ContextResult::kFatalFailure: Failed to create shared context for virtualization. │
│ ││ index > [0625/010807.754805:ERROR:shared_image_stub.cc(537)] SharedImageStub: unable to create context │
│ ││ index > [0625/010807.754827:ERROR:gpu_channel.cc(607)] GpuChannel: Failed to create SharedImageStub │
│ ││ index > [0625/010807.756583:INFO:CONSOLE(9261)] "Error: no-webgl-context", source: (9261) │
│ ││ index > { logger: { mount: '1:08:07 AM' } }