Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Question Lag spikes every 3-4 seconds in Unity play mode while training

Discussion in 'ML-Agents' started by DaisyMeRolln, Aug 27, 2021.

  1. DaisyMeRolln

    DaisyMeRolln

    Joined:
    Jan 14, 2020
    Posts:
    2
    Every 3 to 5 seconds i get 3 lag spikes, every time no matter what.
    I tried to make the scene the simplest possible but it still stutter i dont know what to do,also when it stutter my CPU usage is at 30%-45%.
    The problem seems to be caused by root.DecideAction any help?
     

    Attached Files:

  2. unity_-DoCqyPS6-iU3A

    unity_-DoCqyPS6-iU3A

    Joined:
    Aug 18, 2018
    Posts:
    26
    mlagents is probably processing all of the collected observations and training the neural net.
    During that time it can't provide Unity with new actions, hence the "decide" phase is taking a little longer.

    It is expected behavior.

    You can check your GPU-activity in taskmanager. You should see some usage-spikes at the same time your game is stuttering.
     
    DaisyMeRolln likes this.
  3. DaisyMeRolln

    DaisyMeRolln

    Joined:
    Jan 14, 2020
    Posts:
    2
    Thanks a lot for the answer.
    I have a NVIDIA GeForce GTX 1050 and it should be able to process that without any problem i guess, do you think i can do something to get less spikes or remove them all? Or the only solution is to change pc?
     
  4. unity_-DoCqyPS6-iU3A

    unity_-DoCqyPS6-iU3A

    Joined:
    Aug 18, 2018
    Posts:
    26
    My answer is kind of late, sorry. Think about it this way: your observations will always be collected and then processed all at once.

    So it will always take a non-zero time to process the data.

    You could decrease your buffer-size, or your num-epoch. That will make the motions more fluid, but it *will* hurt the learning performance.