-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adds SubprocessUnityEnvironment for parallel envs #1751
Conversation
Hi @harperj - I have been playing around with spawning environments in my fork of marathon-envs and can share some thoughts and insights: You can see my code here - https://github.com/Sohojoe/marathon-envs/tree/feature/multiple_physics_scenes To switch between a single physics scene and multiple physics scenes, flip line 76 of Assets/ML-Agents/Scripts/EnvSpawner.cs
to change the number of agents update the InferenceNumEnvs. Select the agent from the pulldown menu (Terrain agents dont work yet in multi-physics as I've not updated the ray trace code)
SinglePhysicsScene Pros:
SinglePhysicsScene Cons:
MultiPhysicsScene Pros:
SinglePhysicsScene Cons:
So it would be ideal to support both so users can manage the tradeoff
|
Hi @Sohojoe -- It sounds like you're working on multiple training environments (we have been calling them "areas") within a single Unity executable. I am definitely interested in the separation using different scenes, since as you mentioned, with a single scene adapting the code can be tricky (esp. if we are taking an existing codebase). It may be worth us setting that up as a separate feature to consider in the future. This PR is dealing with an independent issue of launching multiple Unity executables, each of which might have many spaces within it. I think it's still an open question how to balance more areas within a single executable with more parallel executables. H |
0fccdb6
to
c95de25
Compare
Feedback addressed and tests fixed -- PTAL. |
👍 |
0d5da99
to
0cf076a
Compare
0798e8c
to
13b04ac
Compare
Squashed and rebased. Note that subprocess environments won't support custom observations at this time. Just a heads up if there are any final comments -- cc @vincentpierre |
@Sohojoe also interested in whether you've had a chance to take another look at this. We are close to making our next release branch and I wonder how this change interacts with the improvements you've made for the marathon environments. |
@harperj Please rebase and also fix the Codacy thing. @vincentpierre: Can you review the note reg. custom observations as well. |
This commit adds support for running Unity environments in parallel. An abstract base class was created for UnityEnvironment which a new SubprocessUnityEnvironment inherits from. SubprocessUnityEnvironment communicates through a pipe in order to send commands which will be run in parallel to its workers. A few significant changes needed to be made as a side-effect: * UnityEnvironments are created via a factory method (a closure) rather than being directly created by the main process. * In mlagents-learn "worker-id" has been replaced by "base-port" and "num-envs", and worker_ids are automatically assigned across runs. * BrainInfo objects now convert all fields to numpy arrays or lists to avoid serialization issues.
13b04ac
to
0261024
Compare
@eshvk the codacy complaint is that the subclass supports an additional optional parameter (related to custom protos). I think this should be fine. |
…#1751) This commit adds support for running Unity environments in parallel. An abstract base class was created for UnityEnvironment which a new SubprocessUnityEnvironment inherits from. SubprocessUnityEnvironment communicates through a pipe in order to send commands which will be run in parallel to its workers. A few significant changes needed to be made as a side-effect: * UnityEnvironments are created via a factory method (a closure) rather than being directly created by the main process. * In mlagents-learn "worker-id" has been replaced by "base-port" and "num-envs", and worker_ids are automatically assigned across runs. * BrainInfo objects now convert all fields to numpy arrays or lists to avoid serialization issues.
This commit adds support for running Unity environments in parallel.
An abstract base class was created for UnityEnvironment which a new
SubprocessUnityEnvironment inherits from.
SubprocessUnityEnvironment communicates through a pipe in order to
send commands which will be run in parallel to its workers.
A few significant changes needed to be made as a side-effect:
rather than being directly created by the main process.
and "num-envs", and worker_ids are automatically assigned across runs.
serialization issues.