Git Product home page Git Product logo

Comments (5)

shanestorks avatar shanestorks commented on September 16, 2024 1

Hi Mohit,

Thanks for your help! This did the trick.

For some reason I had to specify 1 as the display to startx.py and reconfigure the display Thor uses to :1 in gen/constants.py. Perhaps because I have my EC2 instance enabled for xRDP and it always has some Xorg processes running on :0.

I could be totally wrong there, but nonetheless, thank you for your help, and for providing this great resource to the community!

Best,
Shane

from alfred.

MohitShridhar avatar MohitShridhar commented on September 16, 2024

Hi @shanestorks, thanks for your interest!

Forwarding this from @ekolve:

Running on headless AWS machines is possible, the main requirement is that you use a GPU machine to support OpenGL rendering. I have attached a script 'startx.py', which examines the GPU devices on the host, generates a xorg.conf file and then starts X. You can then run ai2thor as you normally would. By default, the :0.0 display will be used, but if you are running on a machine with more than one GPU, you can address these by modifying the screen component of the display. So :0.0 refers to the first device, :0.1 the second and so on.

startx.py:

#!/usr/bin/env python


import subprocess
import shlex
import re
import platform
import tempfile
import os
import sys

def pci_records():
    records = []
    command = shlex.split('lspci -vmm')
    output = subprocess.check_output(command).decode()

    for devices in output.strip().split("\n\n"):
        record = {}
        records.append(record)
        for row in devices.split("\n"):
            key, value = row.split("\t")
            record[key.split(':')[0]] = value

    return records

def generate_xorg_conf(devices):
    xorg_conf = []

    device_section = """
Section "Device"
    Identifier     "Device{device_id}"
    Driver         "nvidia"
    VendorName     "NVIDIA Corporation"
    BusID          "{bus_id}"
EndSection
"""
    server_layout_section = """
Section "ServerLayout"
    Identifier     "Layout0"
    {screen_records}
EndSection
"""
    screen_section = """
Section "Screen"
    Identifier     "Screen{screen_id}"
    Device         "Device{device_id}"
    DefaultDepth    24
    Option         "AllowEmptyInitialConfiguration" "True"
    SubSection     "Display"
        Depth       24
        Virtual 1024 768
    EndSubSection
EndSection
"""
    screen_records = []
    for i, bus_id in enumerate(devices):
        xorg_conf.append(device_section.format(device_id=i, bus_id=bus_id))
        xorg_conf.append(screen_section.format(device_id=i, screen_id=i))
        screen_records.append('Screen {screen_id} "Screen{screen_id}" 0 0'.format(screen_id=i))
    
    xorg_conf.append(server_layout_section.format(screen_records="\n    ".join(screen_records)))

    output =  "\n".join(xorg_conf)
    print(output)
    return output

def startx(display):
    if platform.system() != 'Linux':
        raise Exception("Can only run startx on linux")

    devices = []
    for r in pci_records():
        if r.get('Vendor', '') == 'NVIDIA Corporation'\
                and r['Class'] in ['VGA compatible controller', '3D controller']:
            bus_id = 'PCI:' + ':'.join(map(lambda x: str(int(x, 16)), re.split(r'[:\.]', r['Slot'])))
            devices.append(bus_id)

    if not devices:
        raise Exception("no nvidia cards found")

    try:
        fd, path = tempfile.mkstemp()
        with open(path, "w") as f:
            f.write(generate_xorg_conf(devices))
        command = shlex.split("Xorg -noreset +extension GLX +extension RANDR +extension RENDER -config %s :%s" % (path, display))
        subprocess.call(command)
    finally: 
        os.close(fd)
        os.unlink(path)


if __name__ == '__main__':
    display = 0
    if len(sys.argv) > 1:
        display = int(sys.argv[1])
    print("Starting X on DISPLAY=:%s" % display)
    startx(display)

from alfred.

707346129 avatar 707346129 commented on September 16, 2024

Hi @MohitShridhar. I ran the code alfred/gen/scripts/generate_trajectories.py on the server and ran into the similar error. The server is not connected to any display. Is there anyway to run the data generation script without display?

from alfred.

707346129 avatar 707346129 commented on September 16, 2024

I ran the startx.py, and it shows "/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server".

from alfred.

MohitShridhar avatar MohitShridhar commented on September 16, 2024

For running on a headless server, see: https://github.com/askforalfred/alfred#cloud-instance

"/usr/lib/xorg/Xorg.wrap: Only console users are allowed to run the X server".

This seems like a permissions issue. Have you looked at this:
https://unix.stackexchange.com/questions/437809/start-x-server-on-login-with-systemd

from alfred.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.