Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Setup VirtualGL and TurboVNC on Ubuntu for OpenGL forwarding

https://github.com/aancel/admin/wiki/VirtualGL-on-Ubuntu

https://virtualgl.org/About/Introduction

https://www.turbovnc.org

VirtualGL

When you use ssh with X forwarding, you might have noticed that you cannot execute programs that require 3D acceleration. That's where VirtualGL comes into play.

VirtualGL is an open source toolkit that gives any Unix or Linux remote display software the ability to run OpenGL applications with full 3D hardware acceleration.

With VirtualGL, the OpenGL commands and 3D data are instead redirected to a 3D graphics accelerator (AKA "graphics processing unit" or "GPU") in the application server, and only the rendered 3D images are sent to the client machine.

Inititalization

Download the following packages for the server:

Installation

  • Make sure you have installed the proprietary drivers for your graphics card (at least for Nvidia that I have tested this setup).

  • Install virtualgl on Ubuntu, by installing the deb file you already downloaded:

sudo dpkg -i virtualgl_*.deb
  • Shutdown the display manager and configure virtualgl server:
# login as root
# If you are using KDE, install lightdm (sudo apt-get install lightdm)
# otherwise the following configuration steps do not work with SDDM (yet)
service lightdm stop
/opt/VirtualGL/bin/vglserver_config
# Go through the questions until the configuration is done.
sudo reboot

# Sanity check for restricted access to 3D X Server
xauth merge /etc/opt/VirtualGL/vgl_xauth_key
xdpyinfo -display :0
/opt/VirtualGL/bin/glxinfo -display :0 -c
# Check that the Graphic card is indeed used and not Mesa

  • Install TurboVNC:
sudo dpkg -i turbovnc_*.deb

For the TurboVNC clients, you can find them at the same address

Use

  • Launch /opt/TurboVNC/bin/vncserver on the server. Possible options:
    • -otp: enable One Time Password
    • -geometry x: specify size of the window
  • Connect using TurboVNC client (/opt/TurboVNC/bin/vncviewer). (The screen will appear black but X is launched)
  • In a terminal on the server
    • export the DISPLAY variable to the value used by vncserver
    export DISPLAY=:1 # if your vncserver started in DISPLAY :1
    
    • Launch an X App (with vglrun to have 3D acceleration)
    # Example command
    vglrun glxgears
    

Tips

  • To get a window manager up and running (in order to not have the black screen) do the following:

    • With the command vncserver -list find the started vnc server. This command will give you an output that looks like this:
    $ vncserver -list
    
    TurboVNC server sessions:
    
    X DISPLAY #     PROCESS ID
    :1              8972
    
    • Kill the started VNC server with the command vncserver -kill :1. Change the :1 with the X DISPLAY value returned by the vncserver -list command earlier.

    • Make sure that the commands xfce4-panel and xfce4-session exist in your system (if not install them), and append the following line at the end of the file ~/.vnc/xstartup.turbovnc.

    xfce4-session &
    
    • Now start the vncserver again:
    /opt/TurboVNC/bin/vncserver
    
  • Export PATH variables:

export PATH=/opt/TurboVNC/bin:$PATH
@lddd

This comment has been minimized.

Copy link

lddd commented Mar 16, 2018

Hello,

i am trying to get any android studio emulator running with OpenGL / GPU support.

I followed the docs here and running "vglrun glxgears" worked fine.

Now i tried starting android studio the same like

/opt/android-studio/bin # vglrun ./studio.sh

It starts Android Studio and i can see everything through TurboVNC Viewer Client now.

But still getting the same errors when trying to run any emulator with Emulated Performance.

10:14 PM	Emulator: failed to create drawable
10:14 PM	Emulator: getGLES2ExtensionString: Could not create GLES 2.x Pbuffer!
10:14 PM	Emulator: Failed to obtain GLES 2.x extensions string!
10:14 PM	Emulator: Could not initialize emulated framebuffer
10:14 PM	Emulator: pulseaudio: pa_context_connect() failed
10:14 PM	Emulator: pulseaudio: Reason: Connection refused
10:14 PM	Emulator: pulseaudio: Failed to initialize PA context
10:14 PM	Emulator: audio: Could not init `pa' audio driver
10:14 PM	Emulator: emulator: ERROR: Missing initial data partition file: /root/.android/avd/Nexus_5X_API_25.avd/userdata.img
10:14 PM	Emulator: emulator: ERROR: Could not initialize OpenglES emulation, use '-gpu off' to disable it.
10:14 PM	Emulator: Process finished with exit code 139 (interrupted by signal 11: SIGSEGV)

Any idea how to get this working?

@maxbader

This comment has been minimized.

Copy link

maxbader commented May 13, 2018

Hi on my Kubuntu 18.04 using turbovnc_2.1.2_amd64.deb and virtualgl32_2.5.90_amd64.deb I got the following error message running the vncviewer

libjawt.so path: /usr/lib/jvm/java-11-openjdk-amd64/lib
Unrecognized option: -d64
Error: Could not create the Java Virtual Machine.
Error: A fatal exception has occurred. Program will exit.

After removing the -d64 option form the last line in /opt/TurboVNC/bin/vncviewer everything started to work again.

@thebetterjort

This comment has been minimized.

Copy link

thebetterjort commented Jun 1, 2018

Could this give Apache Guacamole any benefits in terms of being able to watch video?

@emretekince

This comment has been minimized.

Copy link

emretekince commented Jun 14, 2018

I'm trying to do same thing. Did you able to solve it? @lddd

@boredomdenied

This comment has been minimized.

Copy link

boredomdenied commented Oct 22, 2018

@IDDD @emretekince you need to run adb commands with vglrun. I will spinup instances tomorrow & try this with vnc and as Jenkins builds. More info to follow

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.