Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display exception when creating multiple SMARTS instances #184

Closed
zbzhu99 opened this issue Nov 19, 2020 · 9 comments
Closed

Display exception when creating multiple SMARTS instances #184

zbzhu99 opened this issue Nov 19, 2020 · 9 comments
Assignees
Labels
bug Something isn't working

Comments

@zbzhu99
Copy link
Contributor

zbzhu99 commented Nov 19, 2020

I encounter the "Display is not found" exception when trying to create multiple SMARTS instances:

截屏2020-11-19 10 19 23

To reproduce:

train_env = gym.make(
    "smarts.env:hiway-v0",
    scenarios=scenarios,
    agent_specs={AGENT_ID: agent_spec},
    headless=headless,
    visdom=False,
    timestep_sec=0.1,
    sumo_headless=True,
    seed=seed,
    # envision_record_data_replay_path="./data_replay",
)

test_env = gym.make(
    "smarts.env:hiway-v0",
    scenarios=scenarios,
    agent_specs={AGENT_ID: agent_spec},
    headless=headless,
    visdom=False,
    timestep_sec=0.1,
    sumo_headless=True,
    seed=seed,
    # envision_record_data_replay_path="./data_replay",
)

Development Environment:

OS: Ubuntu 16.04

Python: 3.7.4

SUMO: 1.7.0

SMARTS: 0.4.4

@davidrusu davidrusu self-assigned this Nov 19, 2020
@Gamenot
Copy link
Collaborator

Gamenot commented Nov 19, 2020

Hello @zbzhu99 , this is a known issue. SMARTS uses a few dependencies that have the requirement for a single instance in a process. In order to use another SMARTS instance in the same thread, the previous needs to be destroyed, or run on another process.

There is an example/multi_instance.py that shows one way to be able use more than one smarts environment using ray.

https://github.com/huawei-noah/SMARTS/blob/master/examples/multi_instance.py#L68-L162

@davidrusu
Copy link
Contributor

davidrusu commented Nov 19, 2020

@Gamenot We might be able to solve this problem using the suggestions in this comment here: panda3d/panda3d#996 (comment)

Namely, use the lower level components of panda3d instead of ShowBase

@Gamenot
Copy link
Collaborator

Gamenot commented Nov 19, 2020

@davidrusu Yes, it seems like option 1 from that list of suggestions is the way to go eventually. We are already recommending option 3 via ray but stripping away the globals so that multiple instances can run in the same context would lower complexity for the users

@zbzhu99 zbzhu99 closed this as completed Nov 21, 2020
@zbzhu99 zbzhu99 reopened this Nov 27, 2020
@alek5k
Copy link

alek5k commented Nov 30, 2020

Hi there, I wrote the original github issue over at Panda3D. Just wondering if you'd be willing to share your implementation of the referenced option 1 from my github issue on Panda3D? I ended up going with option 3, but my training time is suffering :\

@davidrusu
Copy link
Contributor

@alek5k We'd be happy to share it once we've got around to tackling this. Currently we are also relying on multiprocessing to avoid multiple instances of Showbase.

If you beat us to it, please come back and share your findings.

@alek5k
Copy link

alek5k commented Dec 8, 2020

Another relevant issue with Panda3D that you might run into if you are planning on running many instances in linux:

panda3d/panda3d#1064

@davidrusu
Copy link
Contributor

@alek5k Yeah we did hit that one with one of our users as well

Maybe you can find something of use from the other configuration options we tuned here:

https://github.com/huawei-noah/SMARTS/blob/master/smarts/core/smarts.py#L62-L68

@liamchzh liamchzh assigned Adaickalavan and unassigned davidrusu Jan 8, 2021
@Gamenot Gamenot added this to the Backlog milestone Jan 27, 2021
@Gamenot Gamenot added the bug Something isn't working label Feb 17, 2021
@Gamenot
Copy link
Collaborator

Gamenot commented Feb 17, 2021

Since we are just using Showbase for the current option figured out here for us in particular is to use a Showbase subclass as a singleton a.k.a. option 2.

@Gamenot
Copy link
Collaborator

Gamenot commented May 27, 2021

This particular problem has been addressed using option 2. The rest of the issue is covered by #743 .

@Gamenot Gamenot closed this as completed May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants