Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

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.