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

RuntimeError when using multiple GPUs #5

Open
yongtaowang327 opened this issue Jul 17, 2022 · 1 comment
Open

RuntimeError when using multiple GPUs #5

yongtaowang327 opened this issue Jul 17, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@yongtaowang327
Copy link

Hi, thanks for releasing the code!

When I tried to use multiple GPUs by model = RotoGrad(backbone, heads, 64, normalize_losses=True), model = torch.nn.DataParallel(model, device_ids=[0,1]).to(torch.device("cuda:0")), there was a RuntimeError:

  File "/data2/wyt/model/monodle_mtl/lib/helpers/trainer_helper.py", line 257, in train_one_epoch
    outputs = self.model(inputs)
  File "/data2/wyt/anaconda3/envs/monodle_mtl/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/data2/wyt/anaconda3/envs/monodle_mtl/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 168, in forward
    outputs = self.parallel_apply(replicas, inputs, kwargs)
  File "/data2/wyt/anaconda3/envs/monodle_mtl/lib/python3.7/site-packages/torch/nn/parallel/data_parallel.py", line 178, in parallel_apply
    return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
  File "/data2/wyt/anaconda3/envs/monodle_mtl/lib/python3.7/site-packages/torch/nn/parallel/parallel_apply.py", line 86, in parallel_apply
    output.reraise()
  File "/data2/wyt/anaconda3/envs/monodle_mtl/lib/python3.7/site-packages/torch/_utils.py", line 461, in reraise
    raise exception
RuntimeError: Caught RuntimeError in replica 0 on device 0.

And when I tried to use single GPU by model = model.to(torch.device("cuda:0")), it looks like no problem.

I'm not sure if this project can support multiple GPUs, or if there is something wrong with my own code. Any help woud be greatly appreciated. Thanks!

@adrianjav
Copy link
Owner

Hi @yongtaowang327,
Sadly, the short answer is no, RotoGrad does not support multiple GPUs.

Personally, I have never needed to use multiple GPUs on my work, so I never thought of adding such a feature to the library. If you can point me out to the requirements to implement such a feature and the changes required are not too complicated (or, even better, if you feel like creating a PR that fixes it), I'd be happy to look into adding support to multiple GPUs.

@adrianjav adrianjav added the enhancement New feature or request label Nov 18, 2022
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

No branches or pull requests

2 participants