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

Errors when trainning models #6

Closed
TrinhTuanHung2021 opened this issue Jul 8, 2022 · 17 comments
Closed

Errors when trainning models #6

TrinhTuanHung2021 opened this issue Jul 8, 2022 · 17 comments

Comments

@TrinhTuanHung2021
Copy link

TrinhTuanHung2021 commented Jul 8, 2022

Hello

Thank you very much for sharing your code

But I had errors when running model at training step with n_workers: 1
I followed your instruction and take

python intersection.py EXP_DIR

Traceback (most recent call last):
File "intersection.py", line 312, in
c.run()
File "/home/osboxes/Desktop/mixed_autonomy_intersections/exp.py", line 357, in run
c.train()
File "/home/osboxes/Desktop/mixed_autonomy_intersections/exp.py", line 289, in train
rollouts = c.rollouts()
File "/home/osboxes/Desktop/mixed_autonomy_intersections/exp.py", line 176, in rollouts
rollout_stats = c.rollouts_single_process()
File "/home/osboxes/Desktop/mixed_autonomy_intersections/exp.py", line 182, in rollouts_single_process
rollout_stats = [c.var(i_rollout=i).rollout() for i in range(c.n_rollouts_per_worker)]
File "/home/osboxes/Desktop/mixed_autonomy_intersections/exp.py", line 182, in
rollout_stats = [c.var(i_rollout=i).rollout() for i in range(c.n_rollouts_per_worker)]
File "/home/osboxes/Desktop/mixed_autonomy_intersections/exp.py", line 201, in rollout
ret = c._env.reset()
File "/home/osboxes/Desktop/mixed_autonomy_intersections/env.py", line 1029, in reset
return self.norm_obs(self.env.reset())
File "intersection.py", line 108, in reset
ret = super().init_env()
File "/home/osboxes/Desktop/mixed_autonomy_intersections/env.py", line 932, in init_env
ret = self.step()
File "intersection.py", line 144, in step
super().step()
File "/home/osboxes/Desktop/mixed_autonomy_intersections/env.py", line 894, in step
self.ts.step()
File "/home/osboxes/Desktop/mixed_autonomy_intersections/env.py", line 791, in step
edge = self.edges[veh.road_id]
KeyError: ''

@TrinhTuanHung2021
Copy link
Author

I used Sumo version 1.13.0.

image

@ZhongxiaYan
Copy link
Owner

Hey, beside your command, are you using any input files (it sounds like you put n_workers=1 into a yaml file)? Can you run find EXP_DIR and send the list of file names to me?

@TrinhTuanHung2021
Copy link
Author

TrinhTuanHung2021 commented Jul 8, 2022

Hey, beside your command, are you using any input files (it sounds like you put n_workers=1 into a yaml file)? Can you run find EXP_DIR and send the list of file names to me?

Thank you for replying to me.
I used n_workers=1 into a yaml file to train

And after running find EXP_DIR

(MAI) osboxes@osboxes:~/Desktop/mixed_autonomy_intersections$ find EXP_DIR
EXP_DIR
EXP_DIR/models
EXP_DIR/models/model-0.pth
EXP_DIR/events.out.tfevents.1657280878.osboxes.4062.0
EXP_DIR/events.out.tfevents.1657262608.osboxes.25073.0
EXP_DIR/sumo
EXP_DIR/sumo/net.xml
EXP_DIR/sumo/add.xml
EXP_DIR/sumo/gui.xml
EXP_DIR/sumo/edg.xml
EXP_DIR/sumo/nod.xml
EXP_DIR/sumo/con.xml
EXP_DIR/train_results.csv
EXP_DIR/2022-07-08T15_27_52.log
EXP_DIR/events.out.tfevents.1657261672.osboxes.24729.0
EXP_DIR/2022-07-08T20_48_23.log
EXP_DIR/config.yaml
EXP_DIR/events.out.tfevents.1657280910.osboxes.4267.0
EXP_DIR/events.out.tfevents.1657280903.osboxes.4191.0
EXP_DIR/commit
EXP_DIR/commit/status.txt
EXP_DIR/commit/diff.txt
EXP_DIR/commit/hash.txt
EXP_DIR/2022-07-08T20_47_57.log
EXP_DIR/2022-07-08T15_43_28.log
EXP_DIR/events.out.tfevents.1657280976.osboxes.4513.0
EXP_DIR/2022-07-08T20_49_36.log
EXP_DIR/2022-07-08T20_48_30.log
(MAI) osboxes@osboxes:/Desktop/mixed_autonomy_intersections$

@TrinhTuanHung2021
Copy link
Author

TrinhTuanHung2021 commented Jul 8, 2022

I can not install Sumo version 1.1.0.
I tried to follow this instruction but I got errors so I used version 1.13

@ZhongxiaYan
Copy link
Owner

I see, is there any other SUMO version that you can install? I would guess that the issue is that a vehicle somehow doesn't have a road_id, which shouldn't happen in SUMO 1.1.0.

So it looks like the program crashes after running for a bit? Does it crash when the first vehicle exits? If that's the case, then maybe in the new SUMO version, the vehicle's road_id gets set to '' when it exits, and you can add an if statement to handle that

@TrinhTuanHung2021
Copy link
Author

I see, is there any other SUMO version that you can install? I would guess that the issue is that a vehicle somehow doesn't have a road_id, which shouldn't happen in SUMO 1.1.0.

So it looks like the program crashes after running for a bit? Does it crash when the first vehicle exits? If that's the case, then maybe in the new SUMO version, the vehicle's road_id gets set to '' when it exits, and you can add an if statement to handle that

I only install Sumo version 1.8.0. It took me a lot of time to downgrade, but I can not install Sumo version 1.1.0 as your instructions.

After running about 17 seconds, the model had errors. Could you show me how to downgrade Sumo to 1.1.0?
image

@ZhongxiaYan
Copy link
Owner

It's probably easier to fix the program rather than installing SUMO 1.1.0 at this point, since many of Mac's packages are now incompatible with 1.1.0. Again, I believe the issue is: "If that's the case, then maybe in the new SUMO version, the vehicle's road_id gets set to '' when it exits, and you can add an if statement to handle that." I'd suggest that you look into the issue from this perspective. SUMO 1.13.0 cannot be totally broken, because it runs for a while. It's probably just a small issue when vehicles exit. I won't be available for the next few days, but you can try this and let me know if it doesn't work

@TrinhTuanHung2021
Copy link
Author

Thank you very much. I will try to find a way to fix it

@TrinhTuanHung2021
Copy link
Author

Hello
I have just build Sumo with 1.1. And I create the new EXP_DIR folder with empty config.yaml
I run your model again with
python intersection.py EXP_DIR

Errors:

(PPO) osboxes@osboxes:~/Desktop/mixed_autonomy_intersections$ python intersection.py EXP_DIR

Traceback (most recent call last):
File "intersection.py", line 263, in
c = GridExp.from_args(globals(), locals())
File "/home/osboxes/Desktop/mixed_autonomy_intersections/u.py", line 800, in from_args
return cls(args.res, **kwargs).save()
File "/home/osboxes/Desktop/mixed_autonomy_intersections/exp.py", line 15, in init
super().init(res, *args, **kwargs)
File "/home/osboxes/Desktop/mixed_autonomy_intersections/u.py", line 739, in init
self.load()
File "/home/osboxes/Desktop/mixed_autonomy_intersections/u.py", line 763, in load
for k, v in self.path.load().items():
AttributeError: 'NoneType' object has no attribute 'items'

@TrinhTuanHung2021
Copy link
Author

I create the new config.yaml with hyperparameter
av_frac: 0.333
directions: 4way
n_cols: 1
n_rollouts_per_step: 256
n_rows: 1
n_workers: 16
worker_kwargs:

  • flow_rate_h: 700
    flow_rate_v: 700
  • flow_rate_h: 850
    flow_rate_v: 850
  • flow_rate_h: 850
    flow_rate_v: 700
  • flow_rate_h: 850
    flow_rate_v: 550
  • flow_rate_h: 850
    flow_rate_v: 400
  • flow_rate_h: 700
    flow_rate_v: 850
  • flow_rate_h: 550
    flow_rate_v: 850
  • flow_rate_h: 400
    flow_rate_v: 850
  • flow_rate_h: 1000
    flow_rate_v: 850
  • flow_rate_h: 1000
    flow_rate_v: 700
  • flow_rate_h: 1000
    flow_rate_v: 550
  • flow_rate_h: 1000
    flow_rate_v: 400
  • flow_rate_h: 850
    flow_rate_v: 1000
  • flow_rate_h: 700
    flow_rate_v: 1000
  • flow_rate_h: 550
    flow_rate_v: 1000
  • flow_rate_h: 400
    flow_rate_v: 1000

and i run your model again
python intersection.py EXP_DIR

Errors

flow_rate_v: 700

  • flow_rate_h: 700
    flow_rate_v: 1000
  • flow_rate_h: 1000
    flow_rate_v: 850
  • flow_rate_h: 850
    flow_rate_v: 1000
    )
    File "/home/osboxes/Desktop/mixed_autonomy_intersections/exp.py", line 182, in rollouts_single_process
    rollout_stats = [c.var(i_rollout=i).rollout() for i in range(c.n_rollouts_per_worker)]
    File "/home/osboxes/Desktop/mixed_autonomy_intersections/exp.py", line 182, in
    rollout_stats = [c.var(i_rollout=i).rollout() for i in range(c.n_rollouts_per_worker)]
    File "/home/osboxes/Desktop/mixed_autonomy_intersections/exp.py", line 201, in rollout
    ret = c._env.reset()
    File "/home/osboxes/Desktop/mixed_autonomy_intersections/env.py", line 1029, in reset
    return self.norm_obs(self.env.reset())
    File "intersection.py", line 106, in reset
    while not self.reset_sumo():
    File "/home/osboxes/Desktop/mixed_autonomy_intersections/env.py", line 910, in reset_sumo
    kwargs = self.def_sumo()
    File "intersection.py", line 19, in def_sumo
    nodes = builder.add_nodes(
    File "/home/osboxes/Desktop/mixed_autonomy_intersections/env.py", line 225, in add_nodes
    ret[:] = nodes
    File "/home/osboxes/Desktop/mixed_autonomy_intersections/env.py", line 67, in getattr
    return self[k]
    File "/home/osboxes/Desktop/mixed_autonomy_intersections/env.py", line 54, in getitem
    return self._dict.getitem(k)
    KeyError: 'array_interface'

@ZhongxiaYan
Copy link
Owner

I see, do you have the newest version of the code? I think I fixed the array_interface issue with this commit d2fbe88

@TrinhTuanHung2021
Copy link
Author

I see, do you have the newest version of the code? I think I fixed the array_interface issue with this commit d2fbe88

Thank you for your quick reply!

Maybe, I used the old version. I downloaded your code by using git clone
Could you please upload your code again?

@ZhongxiaYan
Copy link
Owner

The newest code is already on GitHub, what commit are you on?

@TrinhTuanHung2021
Copy link
Author

The newest code is already on GitHub, what commit are you on?

I have just downloaded it again from GitHub and tried to train or evaluate the old result. But I still had the same error KeyError: '__array_interface__'

@ZhongxiaYan
Copy link
Owner

Hm okay, can you try changing line env.py line 225 to

for i, node in enumerate(nodes):
    ret[i] = node

@TrinhTuanHung2021
Copy link
Author

Hm okay, can you try changing line env.py line 225 to

for i, node in enumerate(nodes):
    ret[i] = node

Thank you very much
I can run your model

Happy mid-autumn festival!

image

@ZhongxiaYan
Copy link
Owner

You too!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants