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
16.93k stars 4.14k forks source link

Couldn't connect to trainer #3128

Closed Rodnyy closed 4 years ago

Rodnyy commented 4 years ago

Describe the bug Hi, I tried to update my version of ml-agents to the most recent one from something pretty old one around 0.7 . So I bumped into a few problems but eventually solved all of them. And created a new project in which I copied the Unity SDK and tried to get used to all the changes... So I started with the 3D Ball example and inference worked just fine but when I tried to do the learning myself inside the unity editor a notification "Couldn't connect to trainer on port 5004 using API version API-12. Will perform inference instead." showed and instead of the learning process, it started inference from the default model. So the learning process ended with a timeout error. I checked the python version inside my "ml-agents\ml-agents-envs\mlagents\envs\environment.py" and it sais API is 12 and then I checked the API in Academy script in my project and it sais API 12 as well. I only noticed that unity mentions 5004 port while the command line mentions 5005 but don't know what it really means. I have also installed Baracuda(0.3.2) through package manager in unity and I am using Unity 2018.3.6f1.

To Reproduce I am not sure I believe I just updated to the newest version and created an empty project and imported unity SDK

Console logs / stack traces Whole message in unity

Couldn't connect to trainer on port 5004 using API version API-12. Will perform inference instead.
UnityEngine.Debug:Log(Object)
MLAgents.Academy:InitializeEnvironment() (at Assets/ML-Agents/Scripts/Academy.cs:319)
MLAgents.Academy:LazyInitialization() (at Assets/ML-Agents/Scripts/Academy.cs:238)
MLAgents.Agent:OnEnable() (at Assets/ML-Agents/Scripts/Agent.cs:255)

Screenshots timeout error error0 error1

Environment (please complete the following information):

I have just probably messed something during the update but I searched the forums and docs and found that some other guys have pretty similar problems but their threads were never solved.

PS: first time posting anything so if you need any more info let me know

Rodnyy commented 4 years ago

So I tried to update Unity to the newest version but it did not help either. Then I tried to play around with Academy script a bit and I changed the port there to 5005 as the command line said but nothing except the number in the Unity notification changed.

afewvowels commented 4 years ago

Have you tried creating a new virtual environment and following the installation instructions for development?

cd ml-agents-envs
pip3 install -e ./
cd ..
cd ml-agents
pip3 install -e ./

I had a lot of trouble getting ml-agents up and running without a virtual environment.

Rodnyy commented 4 years ago

Thank you @afewvowels you probably saved my bachelor thesis. I don't know how it happened but after running the development installation it suggested to me to upgrade the pip and now everything works even without the virtual environment... Thank you once more...

github-actions[bot] commented 3 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.