Search Unity

Resolved Unity Timeout Exception when using Heuristic Only

Discussion in 'ML-Agents' started by reachout, Mar 25, 2021.

  1. reachout

    reachout

    Joined:
    Jan 15, 2021
    Posts:
    10
    I am trying to train an imitation learning agent. I have entered the Heuristic function in my AI so I can control it. But if I select 'Heuristic Only' as behaviour type, the environment crashes after about 50 seconds saying Unity Timeout Exception. Full error message is below. I have Python 3.8.5, Unity 2020.3.0f1. I have tried a different Neural Net. Behaviour Type 'Default' works as expected but I can't train my agent that way. Anyone know how I could get it working again? Thanks.

    Also, I'm using Anaconda3 for the virtual environment. A demo file is still created at the end of the run.

    Code (csharp):
    1.  
    2. (mlagents-r8) E:\Programming\Unity Hub\My projects\Rocket Ball wAI>mlagents-lear
    3. n --time-scale 0.002 --target-frame-rate 60 --run-id P2AIAtt5
    4.  
    5. (Unity logo)
    6.  
    7. Version information:
    8.   ml-agents: 0.25.0,
    9.   ml-agents-envs: 0.25.0,
    10.   Communicator API: 1.5.0,
    11.   PyTorch: 1.8.0
    12. 2021-03-25 22:56:04 INFO [learn.py:245] run_seed set to 7283
    13. 2021-03-25 22:56:04 INFO [torch.py:58] default Torch device: cuda
    14. 2021-03-25 22:56:06 INFO [environment.py:210] Listening on port 5004. Start trai
    15. ning by pressing the Play button in the Unity Editor.
    16. 2021-03-25 22:56:12 INFO [environment.py:112] Connected to Unity environment wit
    17. h package version 1.9.0-preview and communication version 1.5.0
    18. 2021-03-25 22:57:18 INFO [subprocess_env_manager.py:220] UnityEnvironment worker
    19. 0: environment stopping.
    20. 2021-03-25 22:57:18 INFO [trainer_controller.py:81] Saved Model
    21. Traceback (most recent call last):
    22.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\runpy.py", line 194, in _r
    23. un_module_as_main
    24.     return _run_code(code, main_globals, None,
    25.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\runpy.py", line 87, in _ru
    26. n_code
    27.     exec(code, run_globals)
    28.   File "E:\Programming\Anaconda3\envs\mlagents-r8\Scripts\mlagents-learn.exe\__m
    29. ain__.py", line 7, in <module>
    30.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
    31. iners\learn.py", line 250, in main
    32.     run_cli(parse_command_line())
    33.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
    34. iners\learn.py", line 246, in run_cli
    35.     run_training(run_seed, options)
    36.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
    37. iners\learn.py", line 125, in run_training
    38.     tc.start_learning(env_manager)
    39.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents_env
    40. s\timers.py", line 305, in wrapped
    41.     return func(*args, **kwargs)
    42.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
    43. iners\trainer_controller.py", line 173, in start_learning
    44.     self._reset_env(env_manager)
    45.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents_env
    46. s\timers.py", line 305, in wrapped
    47.     return func(*args, **kwargs)
    48.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
    49. iners\trainer_controller.py", line 105, in _reset_env
    50.     env_manager.reset(config=new_config)
    51.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
    52. iners\env_manager.py", line 68, in reset
    53.     self.first_step_infos = self._reset_env(config)
    54.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
    55. iners\subprocess_env_manager.py", line 333, in _reset_env
    56.     ew.previous_step = EnvironmentStep(ew.recv().payload, ew.worker_id, {}, {})
    57.   File "e:\programming\anaconda3\envs\mlagents-r8\lib\site-packages\mlagents\tra
    58. iners\subprocess_env_manager.py", line 98, in recv
    59.     raise env_exception
    60. mlagents_envs.exception.UnityTimeOutException: The Unity environment took too lo
    61. ng to respond. Make sure that :
    62.          The environment does not need user interaction to launch
    63.          The Agents' Behavior Parameters > Behavior Type is set to "Default"
    64.         The environment and the Python interface have compatible versions.
    65.  
     
    Last edited: Mar 25, 2021
  2. reachout

    reachout

    Joined:
    Jan 15, 2021
    Posts:
    10
    Ok, so you don't connect to the port when you're training an imitation learning agent, you just record the demo file. Egg is on my face.