Unity-Technologies / ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
17.04k stars 4.15k forks source link

Learn.py launches unity but it instantly closes and timeouts #892

Closed Temppu7 closed 6 years ago

Temppu7 commented 6 years ago

Hi.

I've been trying to get the ml-agents working, I have set up tensorflow and all of the dependencies, but ran into issues when trying to train the agents.

I have tried to train the practice case of 3DBall, by setting the brain to external and run in background in unity player setting, but when I try to run learn.py to train it, it opens a unity window for a second, then closes it. After a moment it gives following error:

"The Unity environment took too long to respond. Make sure that :\n" 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.

I have tried building the executable in both Unity 2017.1.3 and 2018.1.5, running it with Python 3.6.5 and Tensorflow 1.7.1

Any ideas?

jethros commented 6 years ago

Hey,

I am still having some issues I need to resolve, but I was able to begin to run the training by first checking that the .exe I built was ok and would run without user interaction (setting the Brain Type to external). Perhaps the main cause though, is the quantity of memory that is able to be allocated. I stopped Unity and VS which freed up quite a lot and it ran (to a point) from an Anaconda environment.

Hope this helps.

xiaomaogy commented 6 years ago

@Temppu7 Are you trying this in a Windows environment? How did you setup your python environment?

jethros commented 6 years ago

@Temppu7 As an addition to my note previously, I was able to run the training without an ID for the model so being prompted to run go through the "play" process in Unity.For instance: python learn.py --run-id <identifier for the model> --train I assume this is slower to train but it worked in my case.

Temppu7 commented 6 years ago

@xiaomaogy I'm running in windows, the python was installed with Anaconda and environment was set up closely following the docs. I have checked that all the requirements are installed and also checked that tensorflow works alone.

@jethros I'm pretty sure I'm not running out of memory, I have 16gb in my system which are mostly free.

xiaomaogy commented 6 years ago

@Temppu7 What is the exact command you used for training? Did you do the in-editor training or you built an executable then train it?

Temppu7 commented 6 years ago

@xiaomaogy

python learn.py 3DBall --run-id test --train

I have tried both building an executable and the in-editor training, with similar results.

xiaomaogy commented 6 years ago

@Temppu7 Sorry for the late reply. Can you try:

python learn.py 3DBall --run-id=test --train 

Instead?

Temppu7 commented 6 years ago

@xiaomaogy Tried that also, but still the same result.

xiaomaogy commented 6 years ago

@Temppu7 I've just tried the Unity 2018.1.6 and Unity 2018.1.5 on Windows myself. It still works with In-editor training and the built executable training. (Sorry for the earlier note, earlier I though there was an issue, but it was actually because my master branch was not up to date)

@vincentpierre @awjuliani Please ignore this.

xiaomaogy commented 6 years ago

@Temppu7 Maybe you can try deleting the repo and do a brand new clone of the repo, make sure it is on your master branch.

Also when you build the executable, you will put the executable into a folder, like in ml-agents/python/3dball/ , so that you will have ml-agents/python/3dball/3dball.exe.

Then in the ml-agents/python folder, you try python learn.py 3dball/3dball --train, and it should work.

awjuliani commented 6 years ago

Hi @Temppu7, hopefully you were able to get training working well for you on Windows. I am closing this issue due to inactivity, but feel free to re-open it if you feel necessary.

lock[bot] commented 4 years ago

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.