allenai / ai2thor

An open-source platform for Visual AI.
http://ai2thor.allenai.org
Apache License 2.0
1.16k stars 215 forks source link

Minimal example controller initialization hangs #903

Open dtch1997 opened 3 years ago

dtch1997 commented 3 years ago

I have a minimal example where the program hangs when initializing the controller. When I run the code described below, nothing is printed and the terminal simply hangs indefinitely.

System details:

Minimal example code:

from ai2thor.controller import Controller
controller = Controller(    
    agentMode="default",
    visibilityDistance=1.5,
    scene="FloorPlan212",

    # step sizes
    gridSize=0.25,
    snapToGrid=True,
    rotateStepDegrees=90,

    # image modalities
    renderDepthImage=False,
    renderInstanceSegmentation=False,

    # camera properties
    width=300,
    height=300,
    fieldOfView=90
)
print("Controller initialized")
event = controller.step(action="RotateRight")
print("Step complete")
metadata = event.metadata
print(event, event.metadata.keys())
mattdeitke commented 3 years ago

Hi @dtch1997, are you running on a headless machine (i.e., a machine without an external monitor) by chance?

xubo92 commented 3 years ago

Hi @dtch1997, are you running on a headless machine (i.e., a machine without an external monitor) by chance?

Got the same problem. And yes I was trying to run it on a remote Ubuntu server without a monitor.

How to solve it? Thanks!

ekolve commented 3 years ago

Could you both run the following:

import ai2thor
import ai2thor.controller
c = ai2thor.controller.Controller(download_only=True)
print(ai2thor.__version__)
print(c._build.url)
print(c._build.platform.name)
print(c._build.platform.validate(None))

and respond with the output?

@xubo92 - Are you running within a container or vm?

xubo92 commented 2 years ago

@ekolve @mattdeitke

It has been a long time but I re-encounter this problem and I forget how I solved it earlier.

@ekolve I run your code snippet and here is the error info: File "debug.py", line 3, in <module> c = ai2thor.controller.Controller(download_only=True) File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/ai2thor/controller.py", line 485, in __init__ self._build = self.find_build(local_build, commit_id, branch) File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/ai2thor/controller.py", line 1155, in find_build if build.platform.is_valid(request): File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/ai2thor/platform.py", line 32, in is_valid return len(cls.validate(request)) == 0 File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/ai2thor/platform.py", line 168, in validate elif cls._select_x_display(request.width, request.height) is None: File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/ai2thor/platform.py", line 71, in _select_x_display valid_displays = cls._valid_x_displays(width, height) File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/ai2thor/platform.py", line 147, in _valid_x_displays disp = Xlib.display.Display(":%s" % display_str) File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/Xlib/display.py", line 89, in __init__ self.display = _BaseDisplay(display) File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/Xlib/display.py", line 71, in __init__ protocol_display.Display.__init__(self, *args, **keys) File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/Xlib/protocol/display.py", line 162, in __init__ auth_prot_data = auth_data) File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/Xlib/protocol/display.py", line 1075, in __init__ display.send_and_recv(request = -1) File "/home/xubo/anaconda3/envs/ai2thor/lib/python3.7/site-packages/Xlib/protocol/display.py", line 561, in send_and_recv rs, ws, es = select.select([self.socket], writeset, [], timeout)

Since I run my code on a Ubuntu server without physical monitor, I also try to use startx(). But the error is same as above.

qazwini commented 2 years ago

I am also having a hanging issue. However, it only happens after initializing 20ish controllers. I am also running my code on a Ubuntu server without a physical monitor and running an Xserver with X, but it does not help with my issue.

SH9959 commented 2 weeks ago

What if the output was like:

>>> print(ai2thor.__version__)
5.0.0
>>> print(c._build.url)
http://s3-us-west-2.amazonaws.com/ai2-thor-public/builds/thor-Linux64-f0825767cd50d69f666c7f282e54abfe58f1e917.zip
>>> print(c._build.platform.name)
<bound method BasePlatform.name of <class 'ai2thor.platform.Linux64'>>
>>> print(c._build.platform.validate(None))
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hsong/miniconda3/envs/ai2thor500/lib/python3.8/site-packages/ai2thor/platform.py", line 162, in validate
    if request.headless:
AttributeError: 'NoneType' object has no attribute 'headless'