Repository: stepjam/RLBench
Issue: Cannot run RLBench in headless mode
Root cause: Environment Incompatibility

Hi, 

I am trying to run RLBench on a headless server. I have the same problem with  #89, I have tried @stepjam 's suggestion as in #89  by using

> Xvfb :99 -screen 0 1024x768x24 +extension GLX +render -noreset &
> export DISPLAY=:99
> python3 single_task_rl.py

but I have another problem like this:

```
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_Z11_segHandleri+0x28)[0x7f2adecd60b8]
/lib/x86_64-linux-gnu/libc.so.6(+0x354c0)[0x7f2b459bc4c0]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libQt5Gui.so.5(_ZNK14QOpenGLContext10shareGroupEv+0x0)[0x7f2add5e6060]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libQt5Gui.so.5(_ZN16QOpenGLFunctions25initializeOpenGLFunctionsEv+0x4b)[0x7f2add8b2a4b]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libQt5Gui.so.5(_ZN24QOpenGLFramebufferObjectC1EiiNS_10AttachmentEjj+0xc8)[0x7f2add8b6a18]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libsimExtOpenGL3Renderer.so(_ZN18CFrameBufferObjectC2Eii+0x54)[0x7f2aaff1d3b4]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libsimExtOpenGL3Renderer.so(_ZN16COpenglOffscreenC1EiiiP14QOpenGLContext+0x68)[0x7f2aaff1d758]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libsimExtOpenGL3Renderer.so(_Z21executeRenderCommandsbiPv+0x1f59)[0x7f2aaff1bbd9]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN16CPluginContainer11extRendererEiPv+0x15)[0x7f2adee81065]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN13CVisionSensor24_extRenderer_prepareViewEi+0x34f)[0x7f2adebb1e1f]
QMutex: destroying locked mutex
```

I guess the problem because of the render mode, so I try to change in this line: [https://github.com/stepjam/RLBench/blob/fb62ec8c7b1f9bf5aaa0c9b481f39e7cfed0b535/rlbench/observation_config.py#L13](url) from **RenderMode.OPENGL3** to **RenderMode.OPENGL**, but it has another error:

```
Error: signal 11:

/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_Z11_segHandleri+0x28)[0x7f4c502b20b8]
/lib/x86_64-linux-gnu/libc.so.6(+0x354c0)[0x7f4cb6f984c0]
/lib/x86_64-linux-gnu/libc.so.6(strlen+0x26)[0x7f4cb6fee7c6]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_Z15initGl_ifNeededv+0x116)[0x7f4c5043a5e6]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN19COffscreenGlContextC1EiiiP9QGLWidgetii+0xc9)[0x7f4c50499449]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN20CVisionSensorGlStuffC2EiiibP9QGLWidgetbbii+0x74)[0x7f4c5049b0a4]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN13CVisionSensor45createGlContextAndFboAndTextureObjectIfNeededEb+0x1b8)[0x7f4c5018f6a8]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN13CVisionSensor13detectEntity2Eibbbb+0x1f6)[0x7f4c50194016]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN13CVisionSensor44detectVisionSensorEntity_executedViaUiThreadEibbbb+0x7f)[0x7f4c5019431f]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN9CUiThread27__executeCommandViaUiThreadEP16SUIThreadCommandS1_+0x1db6)[0x7f4c503f6666]
QMutex: destroying locked mutex
```

Can anyone help me with this? thank a lot. Here is the script to reproduce my problem:

```
from rlbench.environment import Environment
from rlbench.action_modes import ActionMode, ArmActionMode
from rlbench.tasks import ReachTarget

action_mode = ActionMode(ArmActionMode.DELTA_EE_POSE_WORLD_FRAME)
env = Environment(action_mode, robot_configuration='panda', headless=True)
env.launch()

task = env.get_task(ReachTarget)
task.reset()
```



Hi,
When you run `env.launch()`, there should be a lot of output from CoppeliaSim as it launches. Could you share that output please?

Hi, 
Thank you for reply. Here is my output of `env.launch()`

```
[CoppeliaSim:loadinfo]   CoppeliaSim V4.1.0., (rev. 1), flavor: 1
[CoppeliaSim:loadinfo]   Legacy machine ID: 5000-9DEB-FFC4-9CEC-F7E3-841D
[CoppeliaSim:loadinfo]   Machine ID: D330-7365-6382-0000-AF39-0101
[CoppeliaSim:loadinfo]   using the default Lua library.
[CoppeliaSim:loadinfo]   simulator launched.
[CoppeliaSim:loadinfo]   plugin 'DynamicsBullet-2-78': loading...
[CoppeliaSim:loadinfo]   plugin 'DynamicsBullet-2-78': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'DynamicsBullet-2-83': loading...
[CoppeliaSim:loadinfo]   plugin 'DynamicsBullet-2-83': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'DynamicsNewton': loading...
[CoppeliaSim:loadinfo]   plugin 'DynamicsNewton': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'DynamicsOde': loading...
[CoppeliaSim:loadinfo]   plugin 'DynamicsOde': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'DynamicsVortex': loading...
[CoppeliaSim:loadinfo]   plugin 'DynamicsVortex': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'Geometric': loading...
[CoppeliaSim:loadinfo]   plugin 'Geometric': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'Assimp': loading...
[CoppeliaSim:loadinfo]   plugin 'Assimp': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'BlueZero': loading...
[CoppeliaSim:loadinfo]   plugin 'BlueZero': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'BubbleRob': loading...
[CoppeliaSim:loadinfo]   plugin 'BubbleRob': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'Bwf': loading...
[CoppeliaSim:loadinfo]   plugin 'Bwf': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'CodeEditor': loading...
[simExtCodeEditor:error]   cannot load in headless mode
[CoppeliaSim:error]   plugin 'CodeEditor': load failed (failed initialization).
[CoppeliaSim:loadinfo]   plugin 'Collada': loading...
[simExtCollada:error]   CoppeliaSim runs in headless mode. Cannot start the plugin.
[CoppeliaSim:error]   plugin 'Collada': load failed (failed initialization).
[CoppeliaSim:loadinfo]   plugin 'ConvexDecompose': loading...
[CoppeliaSim:loadinfo]   plugin 'ConvexDecompose': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'CustomUI': loading...
[simExtCustomUI:error]   doesn't work in headless mode
[CoppeliaSim:error]   plugin 'CustomUI': load failed (failed initialization).
[CoppeliaSim:loadinfo]   plugin 'ExternalRenderer': loading...
[CoppeliaSim:loadinfo]   plugin 'ExternalRenderer': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'GLTF': loading...
[CoppeliaSim:loadinfo]   plugin 'GLTF': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'ICP': loading...
[CoppeliaSim:loadinfo]   plugin 'ICP': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'IK': loading...
[CoppeliaSim:loadinfo]   plugin 'IK': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'Image': loading...
[CoppeliaSim:loadinfo]   plugin 'Image': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'K3': loading...
[CoppeliaSim:loadinfo]   plugin 'K3': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'LuaCommander': loading...
[simExtLuaCommander:error]   cannot find the statusbar widget
[CoppeliaSim:error]   plugin 'LuaCommander': load failed (failed initialization).
[CoppeliaSim:loadinfo]   plugin 'LuaRemoteApiClient': loading...
[CoppeliaSim:loadinfo]   plugin 'LuaRemoteApiClient': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'Mtb': loading...
[CoppeliaSim:loadinfo]   plugin 'Mtb': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'OMPL': loading...
[CoppeliaSim:loadinfo]   plugin 'OMPL': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'OpenGL3Renderer': loading...
[CoppeliaSim:loadinfo]   plugin 'OpenGL3Renderer': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'OpenMesh': loading...
[CoppeliaSim:loadinfo]   plugin 'OpenMesh': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'Qhull': loading...
[CoppeliaSim:loadinfo]   plugin 'Qhull': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'ROSInterface': loading...
[CoppeliaSim:error]   plugin 'ROSInterface': load failed (could not load). The plugin probably couldn't load dependency libraries. For additional infos, modify the script 'libLoadErrorCheck.sh', run it and inspect the output.
[CoppeliaSim:loadinfo]   plugin 'RRS1': loading...
[CoppeliaSim:loadinfo]   plugin 'RRS1': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'ReflexxesTypeII': loading...
[CoppeliaSim:loadinfo]   plugin 'ReflexxesTypeII': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'RemoteApi': loading...
[simExtRemoteApi:loadinfo]   starting a remote API server on port 19997
[CoppeliaSim:loadinfo]   plugin 'RemoteApi': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'SDF': loading...
[simExtSDF:error]   doesn't work in headless mode
[CoppeliaSim:error]   plugin 'SDF': load failed (failed initialization).
[CoppeliaSim:loadinfo]   plugin 'SurfaceReconstruction': loading...
[CoppeliaSim:loadinfo]   plugin 'SurfaceReconstruction': load succeeded.
[CoppeliaSim:loadinfo]   plugin 'URLDrop': loading...
[simExtURLDrop:error]   cannot start in headless mode
[CoppeliaSim:error]   plugin 'URLDrop': load failed (failed initialization).
[CoppeliaSim:loadinfo]   plugin 'Urdf': loading...
[CoppeliaSim:error]   plugin 'Urdf': load failed (failed initialization).
[CoppeliaSim:loadinfo]   plugin 'Vision': loading...
[CoppeliaSim:loadinfo]   plugin 'Vision': load succeeded.
[CoppeliaSim:loadinfo]   using the 'Geometric' plugin.
[CoppeliaSim:loadinfo]   using the 'IK' plugin.
[CoppeliaSim:error]   failed creating an offscreen QOpenGLContext. Switching to a hidden QGLWidget.


Error: signal 11:

/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_Z11_segHandleri+0x28)[0x7f55208920b8]
/lib/x86_64-linux-gnu/libc.so.6(+0x354c0)[0x7f55317f84c0]
/lib/x86_64-linux-gnu/libc.so.6(strlen+0x26)[0x7f553184e7c6]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_Z15initGl_ifNeededv+0x116)[0x7f5520a1a5e6]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN19COffscreenGlContextC1EiiiP9QGLWidgetii+0xc9)[0x7f5520a79449]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN20CVisionSensorGlStuffC2EiiibP9QGLWidgetbbii+0x74)[0x7f5520a7b0a4]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN13CVisionSensor45createGlContextAndFboAndTextureObjectIfNeededEb+0x1b8)[0x7f552076f6a8]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN13CVisionSensor13detectEntity2Eibbbb+0x1f6)[0x7f5520774016]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN13CVisionSensor44detectVisionSensorEntity_executedViaUiThreadEibbbb+0x7f)[0x7f552077431f]
/mnt/hdd/tung/workspace/rlbench/CoppeliaSim/libcoppeliaSim.so.1(_ZN9CUiThread27__executeCommandViaUiThreadEP16SUIThreadCommandS1_+0x1db6)[0x7f55209d6666]
```

Same problem here. Any suggestions on how to solve it?

You can now do GPU rendering: https://github.com/stepjam/RLBench/blob/master/README.md#running-headless