Closed narutoten520 closed 4 years ago
I am wondering you may want to see the training process is right or not. So I attach them as follow. Please help check. Many thanks.
(base) C:\Users\user1\rl-agents\scripts>python experiments.py evaluate configs/HighwayEnv/env.json configs/HighwayEnv/agents/DQNAgent/dqn.json --train --episodes=5000
pygame 1.9.6
Hello from the pygame community. https://www.pygame.org/contribute.html
INFO: Making new env: highway-v0
[INFO] NumExpr defaulting to 8 threads.
[WARNING] Preferred device cuda:best unavailable, switching to default cpu
INFO: Creating monitor directory out\HighwayEnv\DQNAgent\run_20200620-121952_24396
INFO: Starting new video recorder writing to C:\Users\user1\rl-agents\scripts\out\HighwayEnv\DQNAgent\run_20200620-121952_24396\openaigym.video.0.24396.video000000.mp4
Traceback (most recent call last):
File "experiments.py", line 148, in brew install ffmpeg
. On most Ubuntu variants, sudo apt-get install ffmpeg
should do it. On Ubuntu 14.04, however, you'll need to install avconv with sudo apt-get install libav-tools
.""")
gym.error.DependencyNotInstalled: Found neither the ffmpeg nor avconv executables. On OS X, you can install ffmpeg via brew install ffmpeg
. On most Ubuntu variants, sudo apt-get install ffmpeg
should do it. On Ubuntu 14.04, however, you'll need to install avconv with sudo apt-get install libav-tools
.
INFO: Finished writing results. You can upload them to the scoreboard via gym.upload('C:\Users\user1\rl-agents\scripts\out\HighwayEnv\DQNAgent\run_20200620-121952_24396')
Hi @narutoten520 It seems the training process is interrupted because it is trying to record videos, but you are missing the ffmpeg / avconv video utilities, so an error is raised.
You can install them with sudo apt-get install ffmpeg
or sudo apt-get install libav-tools
, as mentionned in the error message.
EDIT: since you're on Windows, you should install ffmpeg.exe manually and add it the the PATH environment variable (so it can be found by python)
Alternatively, you can run the training with the --no-display
option, which disables rendering altogether.
Hello @eleurent , many thanks for your guidance, now I can run and test the toolbox now. I checked other questions and found no answers, so I have to bother you again, sorry about that. I have some questions about how to store the training results, hope you can help me:
I can use tensorboard to see the reward, can I store them by adding some codes somewhere, so I can plot my own style of these figures.
In the highway-env, can I store the speed, acceleration and position of the ego vehicle in each episode? I also want plot these figures to see the training performance.
I also want to store the control actions of ego vehicle in each episodes, can I add some codes somewhere to realize that?
Moreover, can I know the position and speed of the surrounding vehicles, I want to see when the ego vehicle overtake them.
Thanks for your help in advance. Best regards.
Note for potential readers: these questions are also related to the rl-agents project.
Hi @narutoten520,
episode_batch.*.stats.json
file in the run directory. Some example code for loading and plotting the data is already available in the scripts/analyze.py script, so you can work from there.info
dict returned by env.step(action) contains some information that are logged in the gym Monitor stats file. The speed is currently available, but you would need to modify the returned info to add acceleration and position.env.step(action)
method.[vehicle.position, vehicle.speed for vehicle in env.road.vehicles]
, but you would need to log them yourself.Does that help?
Hello @eleurent , your answers are very helpful for me without a doubt. I need to understand them one by one slowly as I am a beginner. Today, I was tucked by the analyze.py. I have tried many ways to run it with your usage explanation, but I failed. Please help me. The commands I have tried:
Many error information is the same as: (base) C:\Users\tengl\rl-agents\scripts>python analyze.py run out/HighwayEnv/DQNAgent/run_20200625-221556_12864/openaigym.episode_batch.0.12864.stats.json... --out Figures INFO:root:Fetching data in out\HighwayEnv\DQNAgent\run_20200625-221556_12864\openaigym.episode_batch.0.12864.stats.json... INFO:root:Found 0 runs. Traceback (most recent call last): File "D:\Anacoda\lib\site-packages\pandas\core\indexes\base.py", line 2646, in get_loc return self._engine.get_loc(key) File "pandas_libs\index.pyx", line 111, in pandas._libs.index.IndexEngine.get_loc File "pandas_libs\index.pyx", line 138, in pandas._libs.index.IndexEngine.get_loc File "pandas_libs\hashtable_class_helper.pxi", line 1619, in pandas._libs.hashtable.PyObjectHashTable.get_item File "pandas_libs\hashtable_class_helper.pxi", line 1627, in pandas._libs.hashtable.PyObjectHashTable.get_item KeyError: 'episode'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "analyze.py", line 134, in
Please help me to find the right command to use the analyze.py file. Thanks.
This script is actually very misleading, sorry about that. I'm not really using it anymore (just tensorboard) and was in fact thinking of removing it. The answer is that you should actually give the parent directory that contains your runs, so that they can be averaged. (Yes I know, it's not what is described)
So simply try:
python analyze.py run out/HighwayEnv/DQNAgent
But this script should be fixed / better documented / removed at some point.
Hello @eleurent , Many thanks for your response and sorry for troubling you again. When I use "configs/HighwayEnv/agents/DQNAgent/ego_attention.json" this agent to train any Highway-env, there will be an issue. Hope you can help me!
(base) C:\Users\tengl\rl-agents\scripts>python experiments.py evaluate configs/HighwayEnv/env_obs_attention.json configs/HighwayEnv/agents/DQNAgent/ego_attention.json --train --episodes=10
INFO: Making new env: highway-v0
[INFO] Choosing GPU device: 0, memory used: 195
INFO: Creating monitor directory out\HighwayEnv\DQNAgent\run_20200629-114414_14436
INFO: Starting new video recorder writing to C:\Users\tengl\rl-agents\scripts\out\HighwayEnv\DQNAgent\run_20200629-114414_14436\openaigym.video.0.14436.video000000.mp4
Traceback (most recent call last):
File "experiments.py", line 152, in
(base) C:\Users\tengl\rl-agents\scripts>python experiments.py evaluate configs/HighwayEnv/env.json configs/HighwayEnv/agents/DQNAgent/ego_attention.json --train --episodes=10
INFO: Making new env: highway-v0
[INFO] Choosing GPU device: 0, memory used: 195
INFO: Creating monitor directory out\HighwayEnv\DQNAgent\run_20200629-114727_13208
size mismatch, m1: [1 x 5], m2: [7 x 64] at C:/cb/pytorch_1000000000000/work/aten/src\THC/generic/THCTensorMathBlas.cu:283
Error occurs, No graph saved
Traceback (most recent call last):
File "experiments.py", line 152, in
Thanks a lot! Best regards.
Hi @narutoten520,
env_obs_attention.json
is the proper environment configuration that you should be using with the ego_attention.json
agent configuration.
The error you get is caused by a recent regression in highway-env, presumably introduced by https://github.com/eleurent/highway-env/commit/42a939120952d4b15bb10c1daffd6315cd930eb0, where the observation
variable was renamed to observation_type
.
I will push a fix.
Thanks a lot for your feeback!
Please update the rl-agents
repository to master, and it should be fixed (I just tested locally)
@eleurent The problem is solved. Thanks a lot for your guidance.
@eleurent Hi eleurent, sorry to bother you again. I am not sure you receive my yesterday question or not. So I want to try again. With your help, now I can train and test the Highway-env with DQN. However, when I follow your instruction to see the results with tensorboard, it shows the following error:
(base) C:\Users\user1\rl-agents\scripts>tensorboard --logdir out/HighwayEnv/DQNAgent/run_20200619-114451_13448 TensorBoard 1.15.0 at http://DESKTOP-H6H55DR:6006/ (Press CTRL+C to quit) W0619 11:45:42.685292 19736 core_plugin.py:185] Unable to get first event timestamp for run .: No event timestamp could be found.
I am not sure my training process is right or not because it finishes with only sevaral seconds with 5000 episodes (I am wondering there may no results stored in run-files ). So I attach the run-files to let you check. Thanks for your help and look forward to your response. Best!
run_20200619-114221_19036.zip