Unity freezing when training AI Agent

Hello

I’ve just recently started using ML Agents.
I noticed that Unity freezes for about 2 seconds every 5 seconds when training the AI agents.

Is this normal? Can this be optimized?

Thanks!

it’s normal. You can build your game with “serveroption on” and then over the console give it as a paramter (I think with --env=). That is faster

Where do we set this option? I dont see it in player options, when building?

hello,
yes,when building you can check serverbuild which deactivates all rendering stuff (watch out for use with rendertextures/ visual sensor component, it deactivates it too as far as I know). Then when starting Mlagents over the console you write mlagents-learn env=YourPathToTheBuildDirectory --no-graphics

when using pyhsics, set: time-scale=1 ; gives better results but is slower (the timescale=1 is not actually realtime but 1 physics frame for a FixedStep). Also use cuda if possible, it made my CNN run 10x faster (as expected).

2 Likes