askforalfred / alfred

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

Can't run startx.py inside docker — requires lspci (fixed) and Xorg (UPDATE: fixed) #51

Closed jzhanson closed 3 years ago

jzhanson commented 3 years ago

When I try to run startx.py inside the docker environment, it tells me that there's no lspci command:

Traceback (most recent call last):
  File "alfred/scripts/startx.py", line 97, in <module>
    startx(display)
  File "alfred/scripts/startx.py", line 72, in startx
    for r in pci_records():
  File "alfred/scripts/startx.py", line 15, in pci_records
    output = subprocess.check_output(command).decode()
  File "/usr/lib/python3.5/subprocess.py", line 626, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.5/subprocess.py", line 693, in run
    with Popen(*popenargs, **kwargs) as process:
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'lspci'

This is because the Dockerfile doesn't install pciutils under the apt-get install call. After adding that, startx.py complains about not having Xorg:

Traceback (most recent call last):
  File "startx.py", line 97, in <module>
    startx(display)
  File "startx.py", line 86, in startx
    subprocess.call(command)
  File "/usr/lib/python3.5/subprocess.py", line 557, in call
    with Popen(*popenargs, **kwargs) as p:
  File "/usr/lib/python3.5/subprocess.py", line 947, in __init__
    restore_signals, start_new_session)
  File "/usr/lib/python3.5/subprocess.py", line 1551, in _execute_child
    raise child_exception_type(errno_num, err_msg)
FileNotFoundError: [Errno 2] No such file or directory: 'Xorg'

But when I add xserver-xorg-core and xorg to the apt-get install call in the Dockerfile, scripts/docker_build.py prompts me for the keyboard layout and then freezes/hangs indefinitely:

Configuring keyboard-configuration
----------------------------------

The layout of keyboards varies per country, with some countries having multiple
common layouts. Please select the country of origin for the keyboard of this
computer.

  1. Afghani                                     48. Irish
  2. Albanian                                    49. Italian
  3. Amharic                                     50. Japanese
  4. Arabic                                      51. Japanese (PC-98xx Series)
  5. Arabic (Morocco)                            52. Kazakh
  6. Arabic (Syria)                              53. Khmer (Cambodia)
  7. Armenian                                    54. Korean
  8. Azerbaijani                                 55. Kyrgyz
  9. Bambara                                     56. Lao
  10. Bangla                                     57. Latvian
  11. Belarusian                                 58. Lithuanian
  12. Belgian                                    59. Macedonian
  13. Bosnian                                    60. Maltese
  14. Braille                                    61. Maori
  15. Bulgarian                                  62. Moldavian
  16. Burmese                                    63. Mongolian
  17. Chinese                                    64. Montenegrin
  18. Croatian                                   65. Nepali
  19. Czech                                      66. Norwegian
  20. Danish                                     67. Persian
  21. Dhivehi                                    68. Polish
  22. Dutch                                      69. Portuguese
  23. Dzongkha                                   70. Portuguese (Brazil)
  24. English (Cameroon)                         71. Romanian
  25. English (Ghana)                            72. Russian
  26. English (Nigeria)                          73. Serbian
  27. English (South Africa)                     74. Sinhala (phonetic)
  28. English (UK)                               75. Slovak
  29. English (US)                               76. Slovenian
  30. Esperanto                                  77. Spanish
  31. Estonian                                   78. Spanish (Latin American)
  32. Faroese                                    79. Swahili (Kenya)
  33. Filipino                                   80. Swahili (Tanzania)
  34. Finnish                                    81. Swedish
  35. French                                     82. Switzerland
  36. French (Canada)                            83. Taiwanese
  37. French (Democratic Republic of the Congo)  84. Tajik
  38. French (Guinea)                            85. Thai
  39. Georgian                                   86. Tswana
  40. German                                     87. Turkish
  41. German (Austria)                           88. Turkmen
  42. Greek                                      89. Ukrainian
  43. Hebrew                                     90. Urdu (Pakistan)
  44. Hungarian                                  91. Uzbek
  45. Icelandic                                  92. Vietnamese
  46. Indian                                     93. Wolof
  47. Iraqi
Country of origin for the keyboard:

I've tried the inputs of "26", "English (US)", and "26. English (US)" but it freezes for all three of them.

ai2thor-docker doesn't have these problems and doesn't prompt for keyboard setup, despite also installing xserver-xorg-core and xorg in its Dockerfile.

Changing the first line of the ALFRED Dockerfile from FROM nvidia/cuda:9.0-cudnn7-devel-ubuntu16.04 to FROM nvidia/cuda:11.0-devel-ubuntu18.04 as the ai2thor-docker does (and which I believe to be the correct versions for the machine I'm running on) doesn't seem to solve it.

jzhanson commented 3 years ago

Thanks @ybisk for helping me with this — the solution is not to try to install xorg in the Dockerfile, but to install it inside the Docker container. For some reason, when running through sudo apt-get update and then sudo apt-get install -y xorg it shows the same languages prompt but in a prettier format and actually allows you to select things.

Screen Shot 2020-10-05 at 11 24 40 AM

Then, you will have to run sudo python3 startx.py & (if you don't use sudo it will complain /usr/lib/xorg/ Xorg.wrap: Only console users are allowed to run the X server, which you might be able to solve by changing /etc/X11/Xwrapper.config, but then you have to change the -config path, and it's more of a hassle than using sudo in the Docker container).

If it gives the error

_XSERVTransSocketUNIXCreateListener: ...SocketCreateListener() failed
_XSERVTransMakeAllCOTSServerListeners: server already running
(EE)
Fatal server error:
(EE) Cannot establish any listening sockets - Make sure an X server isn't already running(EE)
(EE)
Please consult the The X.Org Foundation support
         at http://wiki.x.org
 for help.
(EE) Please also check the log file at "/var/log/Xorg.0.log" for additional information.
(EE)
(EE) Server terminated with error (1). Closing log file.

then you should run sudo python3 startx.py 1 & instead so it starts x server on the display descriptor(?) 1 instead of 0, at which point you'll have to modify gen/constants.py to have X_DISPLAY = 1 instead of X_DISPLAY = 0.

MohitShridhar commented 3 years ago

Thanks @jzhanson. I added xserver-xorg to install_deps.sh. With DEBIAN_FRONTEND=noninteractive, it shouldn't ask for the prompt.

Can I close this issue?

jzhanson commented 3 years ago

Great! Do you think pciutils should also be added to the Dockerfile? That's the last thing I was holding out this issue on.

MohitShridhar commented 3 years ago

Yep https://github.com/askforalfred/alfred/blob/master/scripts/install_deps.sh#L35 Thanks!