Skip to content
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] Multithreaded env #591

Closed
vmoens opened this issue Oct 19, 2022 · 6 comments · Fixed by #734
Closed

[Feature Request] Multithreaded env #591

vmoens opened this issue Oct 19, 2022 · 6 comments · Fixed by #734
Assignees
Labels
enhancement New feature or request

Comments

@vmoens
Copy link
Contributor

vmoens commented Oct 19, 2022

Motivation

We have a version of multiprocessed envs, but not multithreaded.
It would be nice to explore how fast these can be, and/or if that would be a viable solution for executing a list of environments simultaneously.

@vmoens vmoens added the enhancement New feature or request label Oct 19, 2022
@vmoens vmoens self-assigned this Oct 19, 2022
@Benjamin-eecs
Copy link
Contributor

I don't think written in python is going to achieve that goal, you can give a look at EnvPool, maybe we can consider envpool integration for accelerated env backend.

@vmoens
Copy link
Contributor Author

vmoens commented Oct 19, 2022

Thanks @Benjamin-eecs
Sure having a look won't hurt!
The issue is that we must use the spawn mp setting, which is much slower than fork (bc it launches independent python session on each process, rather than forking the current one -> each import needs to happen etc).
I was wondering if by using multithreading we could speed this up.
Does it clarify the issue?
Happy to look at EnvPool anyhow!

@Benjamin-eecs
Copy link
Contributor

I was wondering if by using multithreading we could speed this up.

I think because of Python Global Interpreter Lock (GIL), we cannot achieve multi-thread written in Python (only one thread can be running at a time), maybe that's why there's only subproc vecenv written in python on the RL lib market. But maybe it can be faster than spawn mp setting.

@vmoens
Copy link
Contributor Author

vmoens commented Oct 19, 2022

I think because of Python Global Interpreter Lock (GIL), we cannot achieve multi-thread written in Python (only one thread can be running at a time), maybe that's why there's only subproc vecenv written in python on the RL lib market. But maybe it can be faster than spawn mp setting.

Hence my "exploration" claim :)
Let's try to integrate EnvPool then!

@Benjamin-eecs
Copy link
Contributor

Sure, 'd love to do that 😄

@vmoens
Copy link
Contributor Author

vmoens commented Oct 26, 2022

Hey @Benjamin-eecs
We're not able to work on this atm because our team is working with M1 mcbooks, which I believe is not an arch that is supported by EnvPool. So this will be a pending issue for a little while, unless you want to take care of it yourself and/or make EnvPool compatible with M1 :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants