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

multi-gpu training triggers CUDA out of memory error #2456

Closed
griff4692 opened this issue Jul 1, 2020 · 10 comments · Fixed by #2462
Closed

multi-gpu training triggers CUDA out of memory error #2456

griff4692 opened this issue Jul 1, 2020 · 10 comments · Fixed by #2462
Assignees
Labels
bug Something isn't working help wanted Open to be worked on priority: 0 High priority task

Comments

@griff4692
Copy link

Hi -

I am running into issues when going from single to multi-gpu training. Specifically, if I switch the line

pl.Trainer(gpus=1, precision=16, distributed_backend='ddp')

to

pl.Trainer(gpus=4, precision=16, distributed_backend='ddp')

I get the dreaded CUDA out of memory error. Is there any reason why the parallelism causes the GPU to receive more data?

@griff4692 griff4692 added bug Something isn't working help wanted Open to be worked on labels Jul 1, 2020
@github-actions
Copy link
Contributor

github-actions bot commented Jul 1, 2020

Hi! thanks for your contribution!, great first issue!

@justusschock
Copy link
Member

justusschock commented Jul 2, 2020

Hi, what are your outputs of the validation_step? If there are any large tensors, it's likely they get synced back to root GPU by #2434 . We're working on that.

cc @williamFalcon ^^

@griff4692
Copy link
Author

Hi - I actually haven't implemented the validation step yet. this just occurs on the training side

@justusschock
Copy link
Member

what is your gpu consumption on a single gpu (used/available)?

@griff4692
Copy link
Author

On single gpu, I am using 5/11 GB. The problem seems to be that when I switch over to multiple GPUs, there is an explosion of processes created on the first GPU. Any ideas what could be causing this?

Screen Shot 2020-07-02 at 9 32 21 AM

@griff4692
Copy link
Author

Fixed it!. I was calling .to('cuda') on my input tensors in my Dataset __get__item function which caused all the data to be uploaded to the first GPU. Removed that and solved the problem.

@williamFalcon
Copy link
Contributor

@justusschock does that mean we should add back the all reduce for val?

@justusschock
Copy link
Member

No, there were other issues with that as well :D Let's just keep it out for now.

@MuhammadWaleedUsman
Copy link

Fixed it!. I was calling .to('cuda') on my input tensors in my Dataset __get__item function which caused all the data to be uploaded to the first GPU. Removed that and solved the problem.

I have the same issue but couldnt solve it by removing .to('cuda'). when i do this i get error:
RuntimeError: Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same

@ahmadikalkhorani
Copy link

I have the same issue. When I use 2 nodes everything seems fine. However, when I try to increase the number of nodes it causes CUDA out-of-memory error!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Open to be worked on priority: 0 High priority task
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants