run opengl application over ssh
Run OpenGL application over ssh
Problems
OpenGL application can not run through X11 forwarding feature of ssh. For example, when run an opengl application realsense-viewer through ssh using -X option, we’ll face the following error:
# Log in
$ ssh -X jil@192.168.11.22
# Run realsense-viewer
$ realsense-viewer
libGL error: No matching fbConfigs or visuals found
libGL error: failed to load driver: swrast
OpenGL 3.0 or ARB_vertex_array_object extension required!
How to run opengl application through ssh
Quick answer
Use VirtualGL and TurboVNC
Long answer
The’re two approach to run opengl application through ssh : Indirect rendering and Server-Side 3D rendering
virtualGL explained these 2 approaches very well. Please go there if you need more information about these topics.
In short-word, Indirect rendering mean the 3d rendering will be occured on local machine while receiving command from server.
FIGURE 1: Indirect OpenGL Rendering Using GLX
I try some below tutorials but still unable to make it work.
- opengl-hardware-acceleration-through-remote-x11-ssh-connection
- X Window Systemを使ってリモートサーバでOpenGLなプログラムを走らせる方法
- how-to-install-opengl-in-ubuntu-linux.aspx
Server-Side 3D rendering mean the 3d will be rendered on server machine. Laterly only the result image is “screen captured” and foward to local machine. Up to now we have : Out-of-Process (X Proxy), In-process (GLX Interposing). VirtualGL is the software that allow us to do the Server-Side 3D rendering. The architecture is as follow:
FIGURE 6: The VGL Transport: In-Process GLX Forking and Image Encoding
Configuration detail
- We have 2 following machines
- Server : ubuntu 16.04、Use to run opengl applications and 3d rendering
- Client : ubuntu 18.04、Personal PC
- For each machine, the following software are added
Machine | Software | Link |
---|---|---|
Server | virtualgl_2.6.2_amd64.deb | sourceforge |
Server | turbovnc_2.2.3_amd64.deb | sourceforge |
Client | turbovnc_2.2.3_amd64.deb | sourceforge |
Configure server machine
- Configure VirtualGL
# log as root
service lightdm stop
/opt/VirtualGL/bin/vglserver_config
# See link for how to answer question
# For maximum sevurity answer recommended answers
- Create file /etc/systemd/system/turbovncserver@.service on server machine, which has content as follow:
[Unit]
Description=Remote desktop service (VNC)
After=vncserver@1.service
[Service]
Type=forking
User=gachiemchiep
PIDFile=/home/gachiemchiep/.vnc/%H:%i.pid
ExecStartPre=-/opt/TurboVNC/bin/vncserver -kill :%i > /dev/null 2>&1
ExecStart=/opt/TurboVNC/bin/vncserver -geometry 1280x800 :%i
ExecStop=/opt/TurboVNC/bin/vncserver -kill :%i
[Install]
WantedBy=multi-user.target
Note: Please be notify that, i already use the display :1 (port 5901) for normal vnc server. So i use display :2 for turbovnc
- Edit file ~/.vnc/xstartup.turbovnc on server machine and add the following line to the end of file. Please check that xfce desktop was installed
xfce4-session &
- Enable turbovncserver service to be run on :2 display
systemctl enable turbovncserver@2.service
- Reboot
sudo reboot
Configure server machine
No need further configuration
How to use
From client Machinerun vncclient:
/opt/TurboVNC/bin/vncviewer
Select address as {IP_ADDRESS}:{DISPLAY_NUM} (192.168.11.22:2)
Note: for convinient, the password was set be as same as user password
After login, we have the following :
From client Machine, open another terminal. Then use the following commands to run opengl applications.
# ssh -X {IP_ADDRESS}
ssh -X 192.168.11.22
# export DISPLAY=:{DISPLAY_NUM}
export DISPLAY=:2
# run opengl application
realsense-viewer
# or
glxgears
References
- virtualgl’s background
- https://github.com/aancel/admin/wiki/VirtualGL-on-Ubuntu
- https://virtualgl.org/About/Introduction
- https://www.turbovnc.org
- Setup VirtualGL and TurboVNC on Ubuntu for OpenGL forwarding
End
Leave a comment