Farama-Foundation / HighwayEnv

A minimalist environment for decision-making in autonomous driving
https://highway-env.farama.org/
MIT License
2.66k stars 760 forks source link

The simulation screen always stops at the beginning of the third episode #126

Closed Exasor closed 3 years ago

Exasor commented 3 years ago

I run this env through python experiments.py evaluate configs/HighwayEnv/env.json configs/HighwayEnv/agents/DQNAgent/dqn.json --train --episodes=5 and the first 2 episodes are displayed normally but the simulation screen always stops at the beginning of the third episode, I don't know where this issue comes from and sincerely look for help

eleurent commented 3 years ago

Hi @Exasor, This is by design, and the reason is simple: rendering the screen takes more time than simply stepping the simulation, so to train faster by default we only render a small fraction of the episodes while training.

On the contrary, with the --test option, every episode is rendered by default.

If you want to change this behavior, you must change the video_callable argument in https://github.com/eleurent/rl-agents/blob/master/rl_agents/trainer/evaluation.py#L74

By default (None value), it is set here to capped_cubic_video_schedule, a method that only renders episodes in a cubic progression and then every 1000s, i.e. episodes: 1, 2, 8, 27, 64, ..., 1000, 2000, 3000, etc.

But you can set it to any function, for instance lambda episode: True to render all episodes.

Exasor commented 3 years ago

Oh I get it! Thanks for your reply

Exasor commented 3 years ago

Sorry to trouble you again, I have installed pytorch-gpu, so I wonder if this program can utilize gpu to train agent by default or I should make some settings

eleurent commented 3 years ago

Hi again, The simulator itself runs in CPU. But agents can be trained on GPU, for example when they use with neural network function approximation. The settings will depend on which RL library you are using. If you use https://github.com/eleurent/rl-agents/, then GPU is preferred by default if you train a DQN agent. I think GPU is also chosen by default in https://github.com/hill-a/stable-baselines.

Exasor commented 3 years ago

Thanks a lot