allenai/ai2thor

could not connect to X Display: 0

zkytony opened this issue · 1 comments

I am running ai2thor on a Ubuntu 18.04 server. I tried starting an x server with the following command:

sudo Xorg -noreset +extension GLX +extension RANDR +extension RENDER -config xorg_conf :0

and the content of xorg_conf is:

Section "Device"
    Identifier     "Device0"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "PCI:0:30:0"
EndSection


Section "Screen"
    Identifier     "Screen0"
    Device         "Device0"
    DefaultDepth    24
    Option         "AllowEmptyInitialConfiguration" "True"
    SubSection     "Display"
        Depth       24
        Virtual 1024 768
    EndSubSection
EndSection


Section "ServerLayout"
    Identifier     "Layout0"
    Screen 0 "Screen0" 0 0
EndSection

The Xorg command fails and says Cannot establish any listening sockets - Make sure an X server isn't already running(EE)

I checked and it looks like there is an Xorg server running

$ ps -C Xorg
  PID TTY          TIME CMD
 2127 tty1     00:10:28 Xorg
 3301 tty2     00:09:24 Xorg

However, when I try to launch a controller, I get:

/.../python3.8/site-packages/ai2thor/platform.py:154: Us
erWarning: could not connect to X Display: 0, Can't connect to display ":0": b'No protocol spe
cified\n'
  warnings.warn(
/.../python3.8/site-packages/ai2thor/platform.py:154: Us
erWarning: could not connect to X Display: 2, Can't connect to display ":2": [Errno 111] Conne
ction refused
  warnings.warn(
/.../python3.8/site-packages/ai2thor/platform.py:154: Us
erWarning: could not connect to X Display: 3, Can't connect to display ":3": [Errno 111] Conne
ction refused

And the program hangs.

Attempt

I attempted to start another Xorg server at :2. And then set x_display to be :2 as the argument to start the controller. However, this time I get:

Traceback (most recent call last):
...
.../controller.py", line 45, in launch_controller
    controller = Controller(
  File "/...python3.8/site-packages/ai2thor/controller.
py", line 465, in __init__
    self._build = self.find_build(local_build, commit_id, branch)   
  File "/.../python3.8/site-packages/ai2thor/controller.
py", line 1130, in find_build
    if build.platform.is_valid(request):
  File "/.../python3.8/site-packages/ai2thor/platform.py", line 32, in is_valid
    return len(cls.validate(request)) == 0
  File "/.../python3.8/site-packages/ai2thor/platform.py", line 165, in validate
    return cls._validate_screen(
  File "/.../python3.8/site-packages/ai2thor/platform.py", line 118, in _validate_screen
    disp_screen["width_in_pixels"],
TypeError: 'Display' object is not subscriptable

I have no clue how to resolve this. I have gotten this to work on a different machine with the Xorg command at the top. Help is appreciated.

This is resolved!

First I found the right way to generate the xorg config file (reference):

$ nvidia-xconfig

It will complain if you have not had an Xorg config file under /etc/X11/xorg.conf.

Then edit /etc/X11/xorg.conf and add the line:

Virtual 1024 768

in the Section "Screen" block. Then run

sudo Xorg -noreset +extension GLX +extension RANDR +extension RENDER -config /etc/X11/xorg.conf :0

Either :0, :1 or :2 should work (because ai2thor checks for that).