Rock Man
Rock Man

Reputation: 18

ML-Agents: Environment Executables unable to train - Game is launched instead

I have ml-agents up and running. When I run mlagents-learn from the command line, and play the game from the Unity Editor - everything works fine (the agent trains). But when I build the game and try to run mlagents on the executable - no training is preformed. In fact, I believe the python script is getting stuck - I think it runs the game, but never returns to continue executing the code. I have checked this by writing a simple python script to open the game and debug it:

from mlagents_envs.environment import UnityEnvironment
env = UnityEnvironment(file_name=path)
print("yay")

I ran this code on my executable, and the print command was never reached. I know the problem isn't with python, because I managed to get it to work with executables I found online:

In addition, I know the problem is not with the game, because I ran into these problems also with the 3DBall example, and the very simple ball and plane example (https://unity-technologies.github.io/ml-agents/Learning-Environment-Create-New/). Same problem each time: Training works in the editor, but not with the executable.

I suspect something is wrong with the build process, but I don't know what. I followed the instructions here: https://unity-technologies.github.io/ml-agents/Learning-Environment-Executable/ I have selected "Run In Background" in the Player Settings, I have tried with and without "Development Build" - all without success. After hours spent on this issue, I decided to try my luck with posting a bug...

Any help will be appriciated!

The training stuck:

enter image description here

Environment:

Upvotes: 0

Views: 79

Answers (1)

Rock Man
Rock Man

Reputation: 18

If anyone else runs into this problem, I managed to work around it by installing ML-Agents through the Unity Registry in the Package Manager, instead of a local installation. https://docs.unity3d.com/Manual/upm-ui-install.html

Upvotes: 0

Related Questions