edbeeching / godot_rl_agents

An Open Source package that allows video game creators, AI researchers and hobbyists the opportunity to learn complex behaviors for their Non Player Characters or agents
MIT License
942 stars 69 forks source link

Errors with default config: KeyError "observation_space" #4

Closed ashutoshbsathe closed 2 years ago

ashutoshbsathe commented 2 years ago

Hi, I just installed godot_rl_agents as described in the installation instructions. I have been trying to train an agent for one of the default envs but I get the following error

(pid=38965) KeyError: 'observation_space'
(pid=38965) SCRIPT ERROR: handle_message: Invalid get index 'type' (on base: 'Nil').
(pid=38965)    At: res://addons/godot_rl_agents/sync.gdc:172.
Traceback (most recent call last):
  File "/home/ashutosh/HDD/anaconda3/envs/godot_rl/bin/gdrl", line 33, in <module>
    sys.exit(load_entry_point('godot-rl-agents', 'console_scripts', 'gdrl')())
  File "/home/ashutosh/HDD/MachineLearning/godot_rl_agents/godot_rl_agents/core/main.py", line 91, in main
    results = tune.run(
  File "/home/ashutosh/HDD/anaconda3/envs/godot_rl/lib/python3.8/site-packages/ray/tune/tune.py", line 555, in run
    raise TuneError("Trials did not complete", incomplete_trials)

I also manually tried printing json_dict and here are the contents:

{'algorithm': 'PPO', 'stop': {'episode_reward_mean': 5000, 'training_iteration': 1000, 'timesteps_total': 200000000}, 'config': {'env': 'godot', 'env_config': {'framerate': None, 'action_repeat': None, 'show_window': False, 'seed': 0, 'env_path': 'envs/builds/BallChase/ball_chase.x86_64'}, 'framework': 'torch', 'lambda': 0.95, 'gamma': 0.95, 'vf_clip_param': 100.0, 'clip_param': 0.2, 'entropy_coeff': 0.001, 'entropy_coeff_schedule': None, 'train_batch_size': 1024, 'sgd_minibatch_size': 128, 'num_sgd_iter': 16, 'num_workers': 4, 'lr': 0.0003, 'num_envs_per_worker': 16, 'batch_mode': 'truncate_episodes', 'rollout_fragment_length': 32, 'num_gpus': 1, 'model': {'fcnet_hiddens': [256, 256], 'num_framestacks': 4}, 'no_done_at_end': True, 'soft_horizon': True}}

Here's the full log : https://www.toptal.com/developers/hastebin/epovenonow.yaml

Do I absolutely need to keep Godot editor open ? I'm currently using the ball_chase.x86_64 from the repo

Lastly, opening an environment in godot opens with 16 agents together. Is there a way to fix this ?

edbeeching commented 2 years ago

Hi thanks for raising this issue.

Please can you confirm for me your OS (windows, macOS, linux etc) and also that you have installed a release version of the framework, you have not cloned the master branch?

You do not need to have the editor open if you are using an exported binary. The example environments train with 16 parallel agents, but can be exported with less (or more) if you prefer. In future versions this will be an argument to the environment executable.

Please confirm the above and I will look into the issue, I think the most likely cause is that you have not used 0.1 release version.

ashutoshbsathe commented 2 years ago

I'm running linux. And indeed the version was the issue. Thanks a lot for pointing that out.

I actually ran pip install . instead of the editable version. So when I later changed to tag 0.1.0 it wasn't being reflected

With correct version, training indeed seems to work. Closing the issue