ml-agents icon indicating copy to clipboard operation
ml-agents copied to clipboard

"The Unity environment took too long to respond" after migrating from 0.3 to 0.4

Open r-lipton opened this issue 8 years ago • 16 comments

Hi,

I migrated my env to 0.4 from 0.3, and also the python code, but now I get an error running the learn.py:

unityagents.exception.UnityTimeOutException: The Unity environment took too long to respond. Make sure that :
         The environment does not need user interaction to launch
         The Academy and the External Brain(s) are attached to objects in the Scene
         The environment and the Python interface have compatible versions.

The Player.log outputs this

UnloadTime: 2.105000 ms
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libcoreclr.so
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libcoreclr.so
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libcoreclr.so
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libSystem.dylib
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libSystem.dylib.so
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libSystem.dylib
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libcoreclr.so
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libcoreclr.so
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libcoreclr.so
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libSystem.dylib
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libSystem.dylib.so
Fallback handler could not load library /data/home/lipton/ml-agents0.4/python/My_env_Data/Mono/libSystem.dylib
UnityAgentsException: The Communicator was unable to connect. Please make sure the External process is ready to accept communication with Unity.
  at MLAgents.Batcher.SendAcademyParameters (MLAgents.CommunicatorObjects.UnityRLInitializationOutput academyParameters) [0x00032] in <106d9114346542fa97c3096ba4abccff>:0
  at MLAgents.Academy.InitializeEnvironment () [0x001d9] in <106d9114346542fa97c3096ba4abccff>:0
  at MLAgents.Academy.Awake () [0x00000] in <106d9114346542fa97c3096ba4abccff>:0

I ran this command on a Linux based server. The env is built using the headless mode. I had no problem using the 0.3 version. There is not these Fallback handler could not load library using the 0.3 version.

I also tried to train the GridWorld from ml-agents but the same error occurs.

Does anyone has a clue to solve this problem ? Thanks

r-lipton avatar Jun 27 '18 15:06 r-lipton

For linux, currently it only works when you build for x86_64. And we have a detailed documentation here -- https://github.com/Unity-Technologies/ml-agents/blob/master/docs/Training-on-Amazon-Web-Service.md#training-on-ec2-instance. If you follow this documentation and you still have issues, please let me know and I will help with debugging.

xiaomaogy avatar Jun 27 '18 23:06 xiaomaogy

Yes I build for x86_64 and I followed the docs. It worked using the 0.3 version.

r-lipton avatar Jun 28 '18 07:06 r-lipton

@r-lipton What is the env you've built? Have you tried our example environment (like 3dball) and build it using headless mode and try to run it?

Also even before using learn.py to train it, have you tried just running the Unity executable with internal brain embedded? Sometimes the error comes from the Unity executable itself.

xiaomaogy avatar Jun 29 '18 23:06 xiaomaogy

I just tested with the 3dball env using headless mode. It works well using the internal brain, no error. But when I build the env using the External brain and using

from unityagents import UnityEnvironment

env = UnityEnvironment(<your_env>)

I get the same errors Fallback handler could not load library ...

r-lipton avatar Jul 02 '18 09:07 r-lipton

Do we have to install some new dependencies for the 0.4 version on the Unix environment ? The ami changed https://github.com/Unity-Technologies/ml-agents/commit/fcabf95983ca61b8f1f79f6376fd79aff0a5c18c#diff-02b477b6be6c51e7ae352b63b21bd697

r-lipton avatar Jul 02 '18 11:07 r-lipton

I tested also on Windows, I have the same errors I used the last version 0.4.0a and Unity 2018.1.6f1

Begin MonoManager ReloadAssembly
- Completed reload, in  0.143 seconds
<RI> Initializing input.

<RI> Input initialized.

<RI> Initialized touch support.

UnloadTime: 0.725734 ms
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libcoreclr.so
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libcoreclr.so.dll
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libcoreclr.so
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libdl.so
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libdl.so.dll
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libdl.so
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libSystem.dylib
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libSystem.dylib.dll
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libSystem.dylib
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libcoreclr.so
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libcoreclr.so.dll
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libcoreclr.so
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libdl.so
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libdl.so.dll
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libdl.so
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libSystem.dylib
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libSystem.dylib.dll
Fallback handler could not load library C:/Users/rlipton/Documents/Projets/ml-agents04/python/3DBall_Data/Mono/libSystem.dylib

r-lipton avatar Jul 05 '18 13:07 r-lipton

Finally found the problem, a proxy was set.

set HTTP_PROXY=
set HTTPS_PROXY=

r-lipton avatar Jul 05 '18 15:07 r-lipton

@r-lipton I think I am in the same exact situation. I would like to use your solution but I am not sure how. what do you mean by a poxy was set? and can you suggest how to do the changes to solve the problem or look where the issue is? that would really be appreciated. Guido

Guidosalimbeni avatar Jul 11 '18 15:07 Guidosalimbeni

I have the same issue.

cjm715 avatar Aug 02 '18 04:08 cjm715

You should not have any proxy set. You can need to clear your env variable HTTP_PROXY and HTTPS_PROXY

r-lipton avatar Aug 02 '18 07:08 r-lipton

I think they are already cleared.. I typed "echo $HTTP_PROXY" and "echo $HTTPS_PROXY". They both returned empty strings. Is this the proper way to check?

cjm715 avatar Aug 02 '18 16:08 cjm715

You should not have any proxy set. You can need to clear your env variable HTTP_PROXY and HTTPS_PROXY

How i can check those variables? Or clean them if needed?

LokoGD avatar Dec 02 '18 15:12 LokoGD

@LokoGD To clear the an env variable You can use unset so unset HTTP_PROXY and unset HTTPS_PROXY To check the content of a variable you can use echo, like echo $HTTP_PROXY

Coac avatar Dec 02 '18 18:12 Coac

@LokoGD To clear the an env variable You can use unset so unset HTTP_PROXY and unset HTTPS_PROXY To check the content of a variable you can use echo, like echo $HTTP_PROXY

Sorry, im not used to Python at all (it's almost the first time i tried something with it actually ^^), u got what u meant and thanks for the information but, where should this be used and how? In anaconda prompt? Should i use build, play or Jupyter Notebook?

I think my problem has relation with the proxy cause of the error i got: "UnityAgentsException: The Communicator was unable to connect. Please make sure the External process is ready to accept communication with Unity.", i might not be reaching the connection cause of proxy, at least is what i thought.

LokoGD avatar Dec 03 '18 11:12 LokoGD

You can execute these commands inside a bash shell You can also execute them inside jupyter notebook using the ! prefix, like !echo $HTTP_PROXY

Coac avatar Dec 10 '18 23:12 Coac

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

lock[bot] avatar Jan 02 '20 23:01 lock[bot]