-
Notifications
You must be signed in to change notification settings - Fork 725
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
[feature request] Import MPI only when needed #430
Comments
Hello, In fact, they changed that also in the original baselines: openai#689
I would go for something intermediary: try to import mpi in the EDIT: one important thing would be to update the documentation to explain the change/how to have access to all algorithms |
I like this suggestion! I think the tricky parts might be some of the code in |
Not a ton more relevant details except that this is our hilarious workaround for the time being. Looking into this issue right now... edit: Ok, I'll go ahead and try araffin's suggestion:
|
Hello! I'm encountering a similar issue. I am using PPO1 and GAIL, so I need mpi. I am using TF 1.15 and Debian stretch. Any ideas for how to fix this would be appreciated. Thanks! |
Does If that also causes an interpreter hang then the problem is unrelated to Stable Baselines, and you'd be better off asking on |
This hangs as well. I'll ask on their forums, thanks. |
Describe the bug
Only four (DDPG, GAIL, TRPO and PPO1) of the twelve algorithms implemented in Stable Baselines use MPI. However, importing
stable_baselines
-- even if you do not use any of the algorithms -- indirectly executesfrom mpi4py import MPI
.This has a number of issues:
mpi4py
has a binary dependency on OpenMPI, which often needs to be installed especially.mpirun
, even if you only use a single process.SubprocVecEnv
).Code example
I've run into many issues with OpenMPI over time. Never tracked down the root cause satisfactorily. As a recent example, https://github.com/HumanCompatibleAI/imitation/blob/master/src/imitation/scripts/train.py deadlocked inside OpenMPI on Ubuntu 18.04 with OpenMPI 2. It worked fine on a recent Mac OS X install. Previously I've also had issues with OpenMPI 4, and found OpenMPI 3 seems to be the most reliable version.
@shwang @qxcv may have more details on this failure mode.
Suggested Resolution
The two main options I see are:
stable_baselines/__init__.py
to not automatically import all the algorithms. This seems the cleanest, but would introduce a breaking API change: users would need to do e.g.from stable_baselines.ppo1 import PPO1
rather thanfrom stable_baselines import PPO1
. It would speed up importingstable_baselines
though, which right now takes a while.mpi4py
wasn't installed, you would only get an error when you actually run the algorithm.I'm happy to open a PR on this if there's agreement on if/how to resolve this.
The text was updated successfully, but these errors were encountered: