Giter Site home page Giter Site logo

Comments (6)

eerkaijun avatar eerkaijun commented on June 1, 2024 1

Hi @praveen-palanisamy, yeap that solves the problem! Thanks a lot for the help!

from macad-gym.

praveen-palanisamy avatar praveen-palanisamy commented on June 1, 2024

Hi @eerkaijun ,
You are right. The issue is because the Python os module for Windows doesn't have support for getpgid and a few other (UNIX-specific) OS commands.
One workaround is to ask subprocess.Popen to create a new process group (wherein a new process group is created with the process ID as the group ID) which can then be killed/exited programmatically on windows by sending a Ctrl + C or Ctrl + Break event.

In summary, the changes for Windows would be to:

  1. Add creationflags=subprocess.CREATE_NEW_PROCESS_GROUP as a new argument and remove the preexec_fn=os.setsid argument in the following Popen lines:

self._server_process = subprocess.Popen(
("DISPLAY=:8 vglrun -d :7.{} {} {} -benchmark -fps=20"
" -carla-server -world-port={}"
" -carla-streaming-port=0".format(
min_index,
SERVER_BINARY,
self._server_map,
self._server_port,
)),
shell=True,
preexec_fn=os.setsid,
stdout=open(log_file, "w"),
)

self._server_process = subprocess.Popen(
("SDL_VIDEODRIVER=offscreen SDL_HINT_CUDA_DEVICE={}"
" {} {} -benchmark -fps=20 -carla-server"
" -world-port={} -carla-streaming-port=0".format(
min_index,
SERVER_BINARY,
self._server_map,
self._server_port,
)),
shell=True,
preexec_fn=os.setsid,
stdout=open(log_file, "w"),
)

  1. Then, in the cleanup() method listed below:
    def cleanup():
    print("Killing live carla processes", live_carla_processes)
    for pgid in live_carla_processes:
    os.killpg(pgid, signal.SIGKILL)

Send pgid.send_signal(signal.CTRL_BREAK_EVENT)

Hope the above 2-step workaround works out for you.

from macad-gym.

eerkaijun avatar eerkaijun commented on June 1, 2024

Thanks so much for the prompt response! I added the lines that you mentioned, but now I'm getting this error:

Initializing new Carla server...                                                                                        
FATAL ERROR while launching server: <class 'AttributeError'>

from macad-gym.

praveen-palanisamy avatar praveen-palanisamy commented on June 1, 2024

Looks like the error message is clipped/incomplete? Could you please post the full error log or let me know which line cause this error on your end?
Please post the contents of the server_*.log file as well for any additional info.

from macad-gym.

eerkaijun avatar eerkaijun commented on June 1, 2024

The error message is not clipped, there's no more lines except the Fatal ERROR line. From the logs, I can see this, which seems to be an issue with the os library in windows again:

Traceback (most recent call last):
  File "C:\Eer Kai Jun\Autonomous Driving\env\lib\site-packages\macad_gym\carla\multi_env.py", line 221, in <module>
    from ray.rllib.env import MultiAgentEnv
ModuleNotFoundError: No module named 'ray'
DEBUG:macad_gym.carla.multi_env:module 'os' has no attribute 'setsid'

from macad-gym.

praveen-palanisamy avatar praveen-palanisamy commented on June 1, 2024

Ohh. Okay. Yeah, the setsid is also not available on Windows. I unfortunately don't yet have a Windows machine setup to test this out now.
The solution is to remove the preexec_fn=os.setsid argument to Popen. I have update my comment above(#32 (comment)) to include this change as well for Windows support.
Please give it a try with this change and post what you find.

from macad-gym.

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.