UnityTimeOutException

Hi,

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

 File "c:\users\silve\miniconda3\envs\unity\lib\site-packages\mlagents\trainers\subprocess_env_manager.py", line 276, in _step
    raise env_exception
mlagents_envs.exception.UnityTimeOutException: The Unity environment took too long to respond. Make sure that :
         The environment does not need user interaction to launch
         The Agents' Behavior Parameters > Behavior Type is set to "Default"
         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!

Thanks for flagging. I’ll forward this to the team - which version of ML Agents are you using?

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

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

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?

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.

What is the value of the max step field in your Agent script and config?

It is 5000, I have tried others as well :S

Does your agent have a DecisionRequester component?

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.

Ha! Indeed, that was the mistake. Everything works now. Thanks @andrewcoh_unity for your observations!