Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

Question Unity freezing when training AI Agent

Discussion in 'ML-Agents' started by PaeddyZ, Dec 6, 2022.

  1. PaeddyZ

    PaeddyZ

    Joined:
    Jan 28, 2020
    Posts:
    1
    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!
     
  2. GamerLordMat

    GamerLordMat

    Joined:
    Oct 10, 2019
    Posts:
    126
    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
     
  3. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    175
    Where do we set this option? I dont see it in player options, when building?
     
  4. GamerLordMat

    GamerLordMat

    Joined:
    Oct 10, 2019
    Posts:
    126
    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).
     
    Last edited: Dec 27, 2022
    NeneChico likes this.