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

Running PPO on multiple GPU's. #264

Closed
pouyajafarian opened this issue Dec 18, 2020 · 5 comments
Closed

Running PPO on multiple GPU's. #264

pouyajafarian opened this issue Dec 18, 2020 · 5 comments
Labels
custom gym env Issue related to Custom Gym Env duplicate This issue or pull request already exists question Further information is requested

Comments

@pouyajafarian
Copy link

Hello,

I would like to run the PPO algorithm https://stable-baselines3.readthedocs.io/en/master/modules/ppo.html on a Google Cloud VM distributed on multiple GPU's. Looking at the documentation I can find below text:

...creating a multiprocess vectorized wrapper for multiple environments, distributing each environment to its own process, allowing significant speed up when the environment is computationally complex.

Does this mean using the vectorized wrapper I should be able to run on multiple GPU's?

Thanks for your help!

@pouyajafarian pouyajafarian added custom gym env Issue related to Custom Gym Env question Further information is requested labels Dec 18, 2020
@Miffyli
Copy link
Collaborator

Miffyli commented Dec 18, 2020

Hey.

Depends on what you want to parallelize. If you want to parallelize the algorithm updates itself, then no, there is no support for multi-gpu setup right now. Vectorized environments only parallelize environments. If you have compute-heavy environments running them in parallel might speed up gathering samples, but does not affect algorithm training itself.

@araffin araffin added the duplicate This issue or pull request already exists label Dec 18, 2020
@araffin
Copy link
Member

araffin commented Dec 18, 2020

Does this mean using the vectorized wrapper I should be able to run on multiple GPU's?

PPO is quite lightweight, so unless you are using a big network for the policy/value network, I would recommend you to get better cpus rather than more gpu. The bottleneck usually comes from the environment simulation not the gradient update.

Please take a look at the issue checklist next time as it appears to be a duplicate ;)

Related issues:

@araffin araffin closed this as completed Jan 29, 2021
@zichunxx
Copy link

zichunxx commented Jan 8, 2024

Hi! Is it possible to deploy different training tasks on different GPU? All I know is to set device=cpu or cuda. I tried to set device=cuda:1 but I found that the task is still deployed at the default cuda:0. Thanks!

@araffin
Copy link
Member

araffin commented Jan 10, 2024

. I tried to set device=cuda:1 but I found that the task is still deployed at the default cuda:0. Thanks!

could you please open an issue with a minimal code to reproduce? (this seems to be a bug)
Can you try with device=torch.device("cuda:1")?

as a quick fix, you can play with CUDA_VISIBLE_DEVICES env variable to mask the other GPUs.

@zichunxx
Copy link

Hi! I have spent some time to reproduce this error but failed. Currently, device="cuda:1", device=torch.device("cuda:1"), and os.environ['CUDA_VISIBLE_DEVICES'] = "0" are all valid to switch GPU for me. If I met this error again, I will open an issue to let you know. Or maybe I overlooked some details. Thanks for your reply!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
custom gym env Issue related to Custom Gym Env duplicate This issue or pull request already exists question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants