-
Notifications
You must be signed in to change notification settings - Fork 865
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
Switch from nn.DataParallel to nn.DistributedDataParallel for realtime inference #3565
base: master
Are you sure you want to change the base?
Conversation
Job PR-3565-9201202 is done. |
@@ -176,7 +176,7 @@ def infer_batch( | |||
device = torch.device(device_type) | |||
batch_size = len(batch[next(iter(batch))]) | |||
if 1 < num_gpus <= batch_size: | |||
model = nn.DataParallel(model) | |||
model = nn.parallel.DistributedDataParallel(model) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test realtime inference in multi-gpu environment and compare the inference time?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the codes and testing results for 30 runs between DDP and DP. It looks like DDP for real time inference has much high latency contributed by results collection operation. Based on the results, I don't recommend to use DDP for real time inference
Issue #, if available:
Description of changes:
Switch from DataParallel to DistributedDataParallel as recommended in the latest Pytorch doc
However, after switching the real time inference speed has been impacted significantly due to the overhead on spawning new process, collecting the data from these process and moving it between CPU and GPUs. See plot below:
Generating script (requires code change):
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.