Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved UnityTimeOutException

Discussion in 'ML-Agents' started by silverquimera, Feb 18, 2021.

  1. silverquimera

    silverquimera

    Joined:
    Dec 3, 2020
    Posts:
    6
    Hi,

    I have been having issues connecting mlagents-learn/mlagents_env with my project. I get the error:

    Code (csharp):
    1.  File "c:\users\silve\miniconda3\envs\unity\lib\site-packages\mlagents\trainers\subprocess_env_manager.py", line 276, in _step
    2.     raise env_exception
    3. mlagents_envs.exception.UnityTimeOutException: The Unity environment took too long to respond. Make sure that :
    4.          The environment does not need user interaction to launch
    5.          The Agents' Behavior Parameters > Behavior Type is set to "Default"
    6.         The environment and the Python interface have compatible versions.
    I have double checked all the suggestions above: the scene does not need user interaction to lunch, the behavior parameters are set to default and the versions are in accordance with release 12.

    The training works well when I created the on the "Making a New Learning Environment" and for the 3DBall example. However, it does not work with my project. Any suggestions where to look? I also tried to build the project and use the python api. I can create the environment and when I set env.reset(), the game starts but then the same timeout exception is raised.

    Thanks!
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,799
    Thanks for flagging. I'll forward this to the team - which version of ML Agents are you using?
     
  3. silverquimera

    silverquimera

    Joined:
    Dec 3, 2020
    Posts:
    6
    Oh snap. As I mentioned, I was working with release 12 (0.23). But I also tried to work with release 10 (0.22) with no luck. It is frustrating not to know where to luck up to fix the error :S
     
  4. nicoloarena

    nicoloarena

    Joined:
    Oct 3, 2019
    Posts:
    4
    Hi, same problem for me, I'm trying on Google Colab using a server build and no-graphics mode.
    Version information:
    ml-agents: 0.23.0,
    ml-agents-envs: 0.23.0,
    Communicator API: 1.3.0,
    PyTorch: 1.7.0+cu101
     
  5. andrewcoh_unity

    andrewcoh_unity

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    162
    Hi @silverquimera

    Just to understand the situation a bit better, are you using ML-Agents trainers with your own custom environment? I see you are successfully able to run a 3DBall executable, are you having this problem when trying to run with an executable of your own environment? Are you able to train your custom environment in the editor or does the problem persist there as well?
     
  6. silverquimera

    silverquimera

    Joined:
    Dec 3, 2020
    Posts:
    6
    Thanks @andrewcoh_unity! First, I tried with the editor. Since I was having no luck I decided to create the build and try with the API with no luck either.

    With the editor, I see that the game is "running" as if it were training. The BeginEpisode is called, then I see that the CollectObservations method is called, then several BeginEpisodes are called (because the Max Step is reached). Finally, I get the
    mlagents_envs.exception.UnityTimeOutException
    . Yet, the game keeps running as if it were still training. I also see that the OnActionsReceived method is never called a single time.
     
  7. andrewcoh_unity

    andrewcoh_unity

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    162
    What is the value of the max step field in your Agent script and config?
     
  8. silverquimera

    silverquimera

    Joined:
    Dec 3, 2020
    Posts:
    6
    It is 5000, I have tried others as well :S
     
  9. andrewcoh_unity

    andrewcoh_unity

    Unity Technologies

    Joined:
    Sep 5, 2019
    Posts:
    162
    Does your agent have a DecisionRequester component?
     
  10. silverquimera

    silverquimera

    Joined:
    Dec 3, 2020
    Posts:
    6
    Not currently. Should I include one? I thought that component is not mandatory unless one wants to trigger the decision making in some specific way.
     
  11. silverquimera

    silverquimera

    Joined:
    Dec 3, 2020
    Posts:
    6
    Ha! Indeed, that was the mistake. Everything works now. Thanks @andrewcoh_unity for your observations!