ml-agents icon indicating copy to clipboard operation
ml-agents copied to clipboard

Question about acclerate the simulation of executable environment

Open xiaoxuh opened this issue 4 years ago • 4 comments

Is your feature request related to a problem? Please describe. I made an executable Unity environment and attempted to training using Python API, while I found the simulation speed of environment is same as run in unity editor(normal speed). So I'd like to know how to set the training simulation speed(don't use for visual, faster than normal speed)

Describe the solution you'd like Given some demos or documents to this problem

xiaoxuh avatar Dec 31 '21 03:12 xiaoxuh

When you are using Python API, The EngineConfiguration side Channel allows you to modify the time-scale.

See this Python-API image

Woojin-unity-zz avatar Jan 12 '22 10:01 Woojin-unity-zz

Yes, you can set theses settings as follows:

    time_scale = 20
    capture_frame_rate = 60
    target_frame_rate = 300
    eng_channel = EngineConfigurationChannel()
    params_channel = EnvironmentParametersChannel()
    env = UnityEnvironment(file_name=file_name, seed=42, side_channels=[eng_channel, params_channel],
                           base_port=5004 + rank, no_graphics=no_graphics)
    engine_config = {"width": 80,
                     "height": 80,
                     "quality_level": 0,
                     "time_scale": time_scale,
                     "capture_frame_rate": capture_frame_rate,
                     "target_frame_rate": target_frame_rate
                     }
    eng_channel.set_configuration_parameters(**engine_config)

miguelalonsojr avatar Jan 12 '22 19:01 miguelalonsojr

Hi Woojin,

I’ve answered your question on the GitHub issue. Feel free to follow up with me directly or through GitHub. We also have an ml-agents channel on slack that you can reach out on: #devs-ml-agents.

Cheers, Miguel

Miguel Alonso Jr, Ph.D. (he/him) Manager, Behavior Authoring and Training @.*** unity.com

On Jan 12, 2022, at 5:43 AM, Woojin-unity @.***> wrote:

When you are using Python API, The EngineConfiguration side Channel allows you to modify the time-scale.

See this Python-API https://github.com/Unity-Technologies/ml-agents/blob/main/docs/Python-API.md https://user-images.githubusercontent.com/97542081/149125423-8fbf47f3-f9d2-4e2b-90c0-c96743f425b3.png — Reply to this email directly, view it on GitHub https://github.com/Unity-Technologies/ml-agents/issues/5654#issuecomment-1010903797, or unsubscribe https://github.com/notifications/unsubscribe-auth/ASLFC3S4XGKHWAVU5IALBEDUVVLLZANCNFSM5LAV4QZQ. You are receiving this because you were assigned.

miguelalonsojr avatar Jan 12 '22 20:01 miguelalonsojr

@miguelalonsojr @Woojin-unity Thank you very much for your help! I implemented training acceleration in unity executable environment(time-scale=20), but I found another problem:the training speed decreased over time :

image I would like to know what causes this problem and how to solve it. Before that, I also tried to train directly with ML agents. Without packing the environment, the training speed would still decrease.

BTW, I found the edit>project settings>time> time scale in the unity editor able to acclerate the simulation speed. Can I speed up both the Unity environment Settings and ML Agents at the same time? (Theoretically, should get training accelerometers multiplied?)

xiaoxuh avatar Jan 27 '22 08:01 xiaoxuh