huawei-noah / SMARTS

Scalable Multi-Agent RL Training School for Autonomous Driving
MIT License
954 stars 190 forks source link

[Help Request] TraCI could not connect #2127

Closed DOPEMANdd closed 10 months ago

DOPEMANdd commented 10 months ago

High Level Description

Traceback (most recent call last):
  File "train_ppo.py", line 81, in <module>
    state, dones = env.reset(), {"__all__": False}
  File "/data/zhangdi/anaconda3/envs/smart/lib/python3.8/site-packages/gymnasium/wrappers/order_enforcing.py", line 61, in reset
    return self.env.reset(**kwargs)
  File "/data/zhangdi/anaconda3/envs/smart/lib/python3.8/site-packages/gymnasium/core.py", line 453, in reset
    return self.env.reset(seed=seed, options=options)
  File "/data/zhangdi/smart_master/SMARTS/smarts/env/gymnasium/hiway_env_v1.py", line 348, in reset
    observations = self._smarts.reset(
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/smarts.py", line 471, in reset
    raise first_exception
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/smarts.py", line 464, in reset
    return self._reset(scenario, start_time)
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/smarts.py", line 501, in _reset
    self.setup(scenario)
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/smarts.py", line 539, in setup
    provider_state = self._setup_providers(self._scenario)
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/smarts.py", line 1230, in _setup_providers
    new_provider_state = self._handle_provider(provider, provider_error)
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/smarts.py", line 1265, in _handle_provider
    provider_state, recovered = provider.recover(
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/sumo_traffic_simulation.py", line 462, in recover
    raise error
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/smarts.py", line 1228, in _setup_providers
    new_provider_state = provider.setup(scenario)
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/sumo_traffic_simulation.py", line 324, in setup
    self._initialize_traci_conn()
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/sumo_traffic_simulation.py", line 239, in _initialize_traci_conn
    self._traci_conn.setOrder(0)
TypeError: 'NoneType' object is not callable
Exception ignored in: <function SafeBulletClient.__del__ at 0x7fd4b995cd30>
Traceback (most recent call last):
  File "/data/zhangdi/smart_master/SMARTS/smarts/core/utils/pybullet.py", line 52, in __del__
  File "/data/zhangdi/anaconda3/envs/smart/lib/python3.8/site-packages/pybullet_utils/bullet_client.py", line 43, in __del__
TypeError: catching classes that do not inherit from BaseException is not allowed

Version

v1.4.0

Operating System

No response

Problems

No response

Gamenot commented 10 months ago

Hello @DOPEMANdd, thank you for the report. Would you happen to have used the python -O optimization flag?

I think we made a bad assumption that the assert would always be there to prevent other exceptions.

https://github.com/huawei-noah/SMARTS/blob/55187d066a2ff5c3e60abddc27a1ef13399cb6aa/smarts/core/sumo_traffic_simulation.py#L236-L241

I will put out a patch for it.

Gamenot commented 10 months ago

Hello @DOPEMANdd, some progress. I have been looking deeper into the errors provided.

Error 1

I need a bit more information to address this bug.

File "/data/zhangdi/smart_master/SMARTS/smarts/core/sumo_traffic_simulation.py", line 239, in _initialize_traci_conn
self._traci_conn.setOrder(0)
TypeError: 'NoneType' object is not callable

Current patch

Error 2

I have included changes in this patch to make this error go away.

Exception ignored in: <function SafeBulletClient.del at 0x7fd4b995cd30>
Traceback (most recent call last):
File "/data/zhangdi/smart_master/SMARTS/smarts/core/utils/pybullet.py", line 52, in del
File "/data/zhangdi/anaconda3/envs/smart/lib/python3.8/site-packages/pybullet_utils/bullet_client.py", line 43, in del
TypeError: catching classes that do not inherit from BaseException is not allowed

Current patch