GPU Accelerated OpenGL for Robomaker
One way to improve performance, especially of Robomaker, is to enable GPU-accelerated OpenGL. OpenGL can significantly improve Gazebo performance, even where the GPU does not have enough GPU RAM, or is too old, to support Tensorflow.
Desktop
On a Ubuntu desktop running Unity there are hardly any additional steps required.
- Ensure that a recent Nvidia driver is installed and is running.
- Ensure that nvidia-docker is installed; review bin/prepare.shfor steps if you do not want to directly run the script.
- Configure DRfC using the following settings in system.env:- DR_HOST_X=True; uses the local X server rather than starting one within the docker container.
- DR_DISPLAY; set to the value of your running X server, if not set then- DISPLAYwill be used.
 
Before running dr-start-training/dr-start-evaluation ensure that DR_DISPLAY/DISPLAY and XAUTHORITY are defined.
Check that OpenGL is working by looking for gzserver in nvidia-smi.
If DR_GUI_ENABLE=True then the Gazebo UI, rviz and rqt will open up in separate windows. (With multiple workers it can get crowded...)
Remote connection to Desktop
If you want to start training or evaluation via SSH (e.g. to increment the training whilst you are on the go) there are a few steps to do:
- Ensure that you are actually logged in to the local machine (desktop session is running).
- In the SSH terminal:
- Ensure DR_DISPLAYis configured insystem.env. Otherwise runexport DISPLAY=:1. [*]
- Run export XAUTHORITY=/run/user/$(id -u)/gdm/Xauthorityto let X know where the X magic cookie is.
- Run source bin/activate.shas normal.
- Run your dr-start-trainingordr-start-evaluationcommand.
 
- Ensure 
Remark: Setting DISPLAY will lead to certain commands (e.g. dr-logs-sagemaker) starting in a terminal window on the desktop, rather than the output being showhn in the SSH terminal.
Use of DR_DISPLAY is recommended to avoid this.
Headless Server
Also a headless server with a GPU, e.g. an EC2 instance, or a local computer with a displayless GPU (e.g. Tesla K40, K80, M40).
This also applies for a desktop computer where you are not logged in. In this case also disconnect any monitor cables to avoid conflict.
- Ensure that a Nvidia driver and nvidia-docker is installed; review bin/prepare.shfor steps if you do not want to directly run the script.
- Setup an X-server on the host. utils/setup-xorg.shis a basic installation script.
- Configure DRfC using the following settings in system.env:- DR_HOST_X=True; uses the local X server rather than starting one within the docker container.
- DR_DISPLAY; the X display that the headless X server will start on. (Default is- :99, avoid using- :0or- :1as it may conflict with other X servers.)
 
Start up the X server with utils/start-xorg.sh.
If DR_GUI_ENABLE=True then a VNC server will be started on port 5900 so that you can connect and interact with the Gazebo UI.
Check that OpenGL is working by looking for gzserver in nvidia-smi.
WSL2 on Windows 11
OpenGL is also supported in WSL2 on Windows 11. By default an Xwayland server is started in Ubuntu 22.04.
To enable OpenGL acceleration perform the following steps:
- Install x11-server-utils with sudo apt install x11-xserver-utils.
- Configure DRfC using the following settings in system.env:- DR_HOST_X=True; uses the local X server rather than starting one within the docker container.
- DR_DISPLAY=:0; the Xwayland starts on :0 by default.
 
If you want to interact with the Gazebo UI, set DR_DOCKER_STYLE=compose and DR_GUI_ENABLE=True in system.env.