askforalfred / alfred

ALFRED - A Benchmark for Interpreting Grounded Instructions for Everyday Tasks
MIT License
360 stars 77 forks source link

"check_thor.py" incurs the FileExistsError from os.mkfifo. #91

Closed maguro27 closed 3 years ago

maguro27 commented 3 years ago

I met the FileExistsError from os.mkfifo when I ran the check_thor.py after running the docker container based on a slightly modified Dockerfile. The main modification of the Dockerfile is that I change the docker image from nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04 to nvcr.io/nvidia/cudagl:11.1.1-devel-ubuntu18.04 because my GPU machine does not match the NVIDIA driver version (namely, use cuda 11.1 because of using NVIDIA RTX A6000) Moreover, I upgrade the ai2thor from ver. 2.1.0 to ver. 3.3.2 because of https://github.com/askforalfred/alfred/issues/90. The full error message is as follows,

(alfred_env) maguro@s184:~/alfred$ python check_thor.py 
/home/maguro/alfred_env/lib/python3.6/site-packages/ai2thor/controller.py:1198: UserWarning: start method depreciated. The server started when the Controller was initialized.
  "start method depreciated. The server started when the Controller was initialized."
Traceback (most recent call last):
  File "check_thor.py", line 4, in <module>
    c.start()
  File "/home/maguro/alfred_env/lib/python3.6/site-packages/ai2thor/controller.py", line 1209, in start
    self.server.start()
  File "/home/maguro/alfred_env/lib/python3.6/site-packages/ai2thor/fifo_server.py", line 202, in start
    os.mkfifo(self.server_pipe_path)
FileExistsError: [Errno 17] File exists

However, I did not meet any error when I ran the ai2thor minimal example and the exmaple_agent.py of the ai2thor-docker.

the ai2thor minimal example

(alfred_env) maguro@s184:~/projects/ai2thor-docker$ python
Python 3.6.9 (default, Jan 26 2021, 15:33:00) 
[GCC 8.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> from ai2thor.controller import Controller
>>> controller = Controller(scene="FloorPlan10")

>>> event = controller.step(action="RotateRight")
>>> metadata = event.metadata
>>> print(event, event.metadata.keys())
<ai2thor.server.Event at 0x7fca1f41f208
    .metadata["lastAction"] = RotateRight
    .metadata["lastActionSuccess"] = True
    .metadata["errorMessage"] = "
    .metadata["actionReturn"] = None
> dict_keys(['objects', 'isSceneAtRest', 'agent', 'hand', 'arm', 'fov', 'cameraPosition', 'cameraOrthSize', 'thirdPartyCameras', 'collided', 'collidedObjects', 'inventoryObjects', 'sceneName', 'lastAction', 'errorMessage', 'errorCode', 'lastActionSuccess', 'screenWidth', 'screenHeight', 'agentId', 'colors', 'colorBounds', 'flatSurfacesOnGrid', 'distances', 'normals', 'isOpenableGrid', 'segmentedObjectIds', 'objectIdsInBox', 'actionIntReturn', 'actionFloatReturn', 'actionStringsReturn', 'actionFloatsReturn', 'actionVector3sReturn', 'visibleRange', 'currentTime', 'sceneBounds', 'updateCount', 'fixedUpdateCount', 'actionReturn'])

the exmaple_agent.py of the ai2thor-docker

(alfred_env) maguro@s184:~/projects/ai2thor-docker$ python example_agent.py 
Skipping Xorg server - DISPLAY is already running at :1
{'cameraHorizon': 0.0,
 'inHighFrictionArea': False,
 'isStanding': True,
 'name': 'agent',
 'position': {'x': -1.5, 'y': 0.9009982347488403, 'z': -1.5},
 'rotation': {'x': -0.0, 'y': 270.0, 'z': 0.0}}

Additionally, I tried changing tempfile function in the fifo_server.py of the ai2thor The changed lines as follows,

54 - self.tmp_dir = tempfile.TemporaryDirectory()
55 - self.server_pipe_path = os.path.join(self.tmp_dir.name, "server.pipe")
56 - self.client_pipe_path = os.path.join(self.tmp_dir.name, "client.pipe")

54 + self.tmp_dir = tempfile.mkdtemp()
55 + self.server_pipe_path = os.path.join(self.tmp_dir, "server.pipe")
56 + self.client_pipe_path = os.path.join(self.tmp_dir, "client.pipe")

However, I couldn't fix the FileExistError. Next, I tried to changing the start function in the fifo_server.py of the ai2thor

201 -     def start(self):
202 -        os.mkfifo(self.server_pipe_path)
203 -        os.mkfifo(self.client_pipe_path)
204 -        self.started = True

201 +    def start(self):
202 +        if os.path.exists(self.server_pipe_path) or os.path.exists(self.client_pipe_path):
203 +            self.tmp_dir = tempfile.TemporaryDirectory()
204 +            self.server_pipe_path = os.path.join(self.tmp_dir.name, "server.pipe")
205 +            self.client_pipe_path = os.path.join(self.tmp_dir.name, "client.pipe")
206 +        os.mkfifo(self.server_pipe_path)
207 +        os.mkfifo(self.client_pipe_path)
208 +        self.started = True

However, I met another error.

(alfred_env) maguro@s184:~/alfred$ python check_thor.py 
/home/maguro/alfred_env/lib/python3.6/site-packages/ai2thor/controller.py:1198: UserWarning: start method depreciated. The server started when the Controller was initialized.
  "start method depreciated. The server started when the Controller was initialized."
Traceback (most recent call last):
  File "check_thor.py", line 4, in <module>
    c.start()
  File "/home/maguro/alfred_env/lib/python3.6/site-packages/ai2thor/controller.py", line 1220, in start
    self.last_event = self.server.receive()
  File "/home/maguro/alfred_env/lib/python3.6/site-packages/ai2thor/fifo_server.py", line 179, in receive
    metadata, files = self._recv_message()
  File "/home/maguro/alfred_env/lib/python3.6/site-packages/ai2thor/fifo_server.py", line 108, in _recv_message
    header = self.server_pipe.read(self.header_size)  # message type + length
ValueError: read of closed file

How do I fix the FileExistsError? Please lend me your hand.

MohitShridhar commented 3 years ago

@maguro27, I am not sure what is happening here. Can you post it on ai2thor issues? https://github.com/allenai/ai2thor/issues

maguro27 commented 3 years ago

@MohitShridhar Thank you for the recommendation. I'll post the solution if I resolve this issue.

maguro27 commented 3 years ago

It's an easy solution. Line 4 of check_thor.py doesn't need. The solution is as follows,

4 - c.start()
MohitShridhar commented 3 years ago

@maguro27 note that ALFRED might not be compatible with the latest versions of AI2THOR. See this thread: https://github.com/askforalfred/alfred/pull/45

However, you can still use the latest version for pre-training and then finetune on ai2thor==2.1.0 with ALFRED data.

maguro27 commented 3 years ago

@MohitShridhar Thank you for the notification! Hmm... I cannot fix the ConnectionResetError of https://github.com/askforalfred/alfred/issues/90 when I use ai2thor==2.1.0. I post the above issue to issue of the ai2thor repository. If I fix the ConnectionResetError, I add a solution to https://github.com/askforalfred/alfred/issues/90.