How to gather results on multiple GPUs while testing? ddp #1974
-
❓ Questions and HelpWhat is your question?I want to test summarization model from huggingface summarization example on multiple GPUs . My problem is how could I collect test results on different GPUs , since Code
What have you tried?For now, I can only use single GPU to get result of whole dataset. What's your environment?
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
Use Here is the workaround snippet used in my own project.
In the above code, you need the index of each example to remove redundant examples and sort outputs in order. |
Beta Was this translation helpful? Give feedback.
-
Thanks to @haichao592 👍 |
Beta Was this translation helpful? Give feedback.
Use
torch.distributed.all_gather
to gather and merge the outputs from all GPUs.And you should remove the redundant examples due to the ddp_sampler adds extra examples to work with multi GPUS. (https://pytorch.org/docs/stable/_modules/torch/utils/data/distributed.html#DistributedSampler)
Here is the workaround snippet used in my own project.