VirtualGL

From Leo's Notes
Last edited on 30 December 2021, at 01:12.


Installation

Download the RPM packages from VirtualGL's repository (on SourceForge) and install it. You may then use the included helper script at /opt/VirtualGL/bin/vglserver_config to set up your system. The script writes to various places., including /etc/security/console.perms, /etc/modprobe.d/virtualgl.conf, /etc/X11/xorg.conf.d/99-virtualgl-dri.

Applications using VirtualGL are executed using the vglrun script which injects a library that redirects OpenGL calls so they render on a local target display (the VGL_DISPLAY). Because each Xorg server uses a Xauth cookie for authentication, vglrun will also try to read this Xauth cookie from /etc/opt/VirtualGL/vgl_xauth_key. For VirtualGL to work, we also need to write the Xauth cookie at this location for the screen the user is trying to render to.

The vgl_xauth_key file can be created using the /usr/bin/vglgenkey script or manually using xauth. If using a login manager like LightDM or GDM, you will need to have the login manager run the vglgenkey script on startup. For systems with multiple GPUs, you will need to start a Xorg server on each GPU and have the vgl_xauth_key contain every cookie or somehow setup the user's xauth cookie list prior to running vglrun.


Using the login manager's X11 server

LightDM

Install LightDM and configure the seats to generate a key.

[Seat:seat0]
display-setup-script=/usr/bin/vglgenkey

Starting X11 Manually

This method gives you full control over which Xorg server starts on which GPU.

Create a xorg.conf file. You may generate one using Nvidia's nvidia-xconfig utility, but this tool doesn't support multiple GPUs. It's a good starting point however, because you just need to duplicate the Screen/Device sections for each of the additional GPUs you want to use with VirtualGL.

# nvidia-xconfig --use-display-device=none --busid="PCI:6:0:0"

Create an xauth cookie for each X11 server and then start each X11 server. Merge all cookies into the vgl_xauth_key file so vglrun works.

Usage

The idea with VirtualGL is that the program you wish to have GPU acceleration renders locally (ie. the remote host that's running the login manager) and VirtualGL then copies the framebuffer back to you. As a result, anything you do run with VirtualGL can appear on the local display which could be a security risk for workstations (such as in a lab setting).

To run a specific application with VirtualGL, use the vglrun command. To help debug issues, use the +v flag to enable verbose logging.

A few environment variables you should be aware of:

  • VGL_DISPLAY should point to the local display with the login manager. (eg. :0)
  • DISPLAY or the -display option should be set to the target display (eg. :1.0, or whatever your display is in a VNC session)
  • VGL_VERBOSE enables debugging
  • VGL_LOGO will print 'VGL' on the window to show that it's rendering with VirtualGL.