Ubuntu 18.04 Uses LLVM instead of NVIDIA Drivers for OpenGL

In order to use GLX on an NVIDIA GPU, you need to have an active X screen on it. It looks like your X server is defaulting to using the ASPEED graphics device rather than one of the NVIDIA GPUs so no NVIDIA render is available to your GLX applications.

With a more modern X server, the server would automatically create “GPU screens” for the NVIDIA GPUs which would allow using those GPUs for GLX rendering using the new “PRIME” render offload support. Unfortunately, the X server on your system is too old to support that.

Alternatively, you could create an /etc/X11/xorg.conf file that creates a separate X screen per GPU. You can do that with nvidia-xconfig --enable-all-gpus.

Finally, if your application can use EGL instead of GLX and doesn’t need to display anything on a physical display device then you should be able to use the EGLDevice extensions to render directly on an NVIDIA GPU, bypassing the Xorg server.