Repository: stepjam/RLBench
Issue: Problems for Running Headless
Root cause: Environment Incompatibility

Hi all, I got some issue about running headless. I followed instructions in `READMD.md` in PyRep and RLBench.

For PyRep, I ran the following command.
```
nohup sudo X &
export DISPLAY=:0.0
cd  examples
python example_reinforcement_learning_env.py
```
Then, I got the output shown below.
```
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::setCompositionMode: Painter not active
QWidget::paintEngine: Should no longer be called
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::setPen: Painter not active
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled


Error: signal 11:

/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_Z11_segHandleri+0x28)[0x7f15c2d8b0b8]
/lib/x86_64-linux-gnu/libc.so.6(+0x354c0)[0x7f15d1bed4c0]
/lib/x86_64-linux-gnu/libc.so.6(strlen+0x26)[0x7f15d1c437c6]
/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_Z15initGl_ifNeededv+0x116)[0x7f15c2f135e6]
/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_ZN11CMainWindowC1Ev+0x6aa)[0x7f15c31ce6da]
/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_ZN3App16createMainWindowEv+0x46)[0x7f15c2f054d6]
/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_Z24simRunSimulator_internalPKciPFvvES2_S2_iS0_b+0x354)[0x7f15c2da01d4]
/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_Z29simExtLaunchUIThread_internalPKciS0_S0_+0x91)[0x7f15c2da0591]
/home/ethan/anaconda3/envs/conti-manipulation/lib/python3.7/site-packages/pyrep/backend/_sim_cffi.cpython-37m-x86_64-linux-gnu.so(+0x52dae)[0x7f15c38d0dae]
python(_PyMethodDef_RawFastCallKeywords+0x1df)[0x563b7dca7def]
```
---
For RLBench, I ran the following command.
```
nohup sudo X &
export DISPLAY=:0.0
cd  examples
python single_task_rl.py
```
Then, I got the output shown below.
```
QPainter::begin: Paint device returned engine == 0, type: 3
QPainter::setCompositionMode: Painter not active
QWidget::paintEngine: Should no longer be called
QPainter::begin: Paint device returned engine == 0, type: 1
QPainter::setPen: Painter not active
QXcbIntegration: Cannot create platform OpenGL context, neither GLX nor EGL are enabled


Error: signal 11:

/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_Z11_segHandleri+0x28)[0x7ff80129e0b8]
/lib/x86_64-linux-gnu/libc.so.6(+0x354c0)[0x7ff8101004c0]
/lib/x86_64-linux-gnu/libc.so.6(strlen+0x26)[0x7ff8101567c6]
/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_Z15initGl_ifNeededv+0x116)[0x7ff8014265e6]
/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_ZN11CMainWindowC1Ev+0x6aa)[0x7ff8016e16da]
/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_ZN3App16createMainWindowEv+0x46)[0x7ff8014184d6]
/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_Z24simRunSimulator_internalPKciPFvvES2_S2_iS0_b+0x354)[0x7ff8012b31d4]
/home/ethan/Dependencies/CoppeliaSim_Edu_V4_1_0_Ubuntu16_04/libcoppeliaSim.so.1(_Z29simExtLaunchUIThread_internalPKciS0_S0_+0x91)[0x7ff8012b3591]
/home/ethan/anaconda3/envs/conti-manipulation/lib/python3.7/site-packages/pyrep/backend/_sim_cffi.cpython-37m-x86_64-linux-gnu.so(+0x52dae)[0x7ff801de3dae]
python(_PyMethodDef_RawFastCallKeywords+0x1df)[0x5616a6ed3def]
```
---

I also tried to run **CoppeliaSim** with the following command.
```
nohup sudo X &
export DISPLAY=:0.0
bash coppeliaSim.sh
```
The output is shown below.
```
[CoppeliaSimClient]    loading the CoppeliaSim library...
[CoppeliaSimClient]    done.
[CoppeliaSimClient:loadinfo]   launching CoppeliaSim...
[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: 1895-3B4B-A58A-0000-DE32-0101
[CoppeliaSim:loadinfo]   using the default Lua library.
[CoppeliaSim:loadinfo]   loaded the video compression library.
Fontconfig warning: ignoring UTF-8: not a valid region tag
[CoppeliaSim:loadinfo]   if CoppeliaSim crashes now, try to install libgl1-mesa-dev on your system:
        >sudo apt install libgl1-mesa-dev


Error: signal 11:

libcoppeliaSim.so(_Z11_segHandleri+0x28)[0x7ff359d270b8]
/lib/x86_64-linux-gnu/libc.so.6(+0x354c0)[0x7ff35db4a4c0]
/lib/x86_64-linux-gnu/libc.so.6(strlen+0x26)[0x7ff35dba07c6]
libcoppeliaSim.so(_Z15initGl_ifNeededv+0x116)[0x7ff359eaf5e6]
libcoppeliaSim.so(_ZN11CMainWindowC1Ev+0x6aa)[0x7ff35a16a6da]
libcoppeliaSim.so(_ZN3App16createMainWindowEv+0x46)[0x7ff359ea14d6]
libcoppeliaSim.so(_Z24simRunSimulator_internalPKciPFvvES2_S2_iS0_b+0x354)[0x7ff359d3c1d4]
libcoppeliaSim.so(simRunSimulatorEx+0xf)[0x7ff359d24a7f]
./coppeliaSim[0x401dfe]
./coppeliaSim[0x4012e8]
```
I also ran `sudo apt install libgl1-mesa-dev`, but I got the same result.

---
Just wonder whether there is any solution for this issue.
Any help appreciated :)

what happens if you run `sudo X` first, then `nvidia-smi`? 
I think you should see Xorg running like
```
+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID   Type   Process name                             Usage      |
|=============================================================================|
|    0     10249      G   /usr/lib/xorg/Xorg                            10MiB |
```
I had similar `Error: signal 11:` before, once you get it out from`bash coppeliaSim.sh` things should be fine, GL!

Thanks @MandiZhao 
@WeiChengTseng  please reopen if you need further help.