-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
MMDataParallel Implementation inconsistency between CPU / GPU #792
Comments
I have found another inconsistency between GPU and GPU from mmcv.parallel import scatter_kwargs, DataContainer
import torch
inputs = (torch.zeros([20, 3, 128, 128]), )
output, _ = scatter_kwargs(inputs, {}, [-1], 0)
print('CPU', output[0][0].size())
output, _ = scatter_kwargs(inputs, {}, [0], 0)
print('GPU', output[0][0].size())
print('------------')
inputs = (DataContainer([torch.zeros([20, 3, 128, 128])]),)
output, _ = scatter_kwargs(inputs, {}, [-1], 0)
print('CPU', output[0][0].size())
output, _ = scatter_kwargs(inputs, {}, [0], 0)
print('GPU', output[0][0].size())
you can see that CPU return wrong size when compare to GPU implementation |
Thanks for reporting this issue, we'll carefully check the inconsistency. |
Hi, I find that updating to if obj.cpu_only or target_gpus == [-1]: fix the issue, however I have not run unittest on the change yet |
Thanks for your information. We'll update the codes accordingly. |
I have investigate the issue deeper and find that mmcv do not intend to support CPU training. I will close this issue. |
It seems that MMDataParallel support CPU only mode.
However, https://github.com/open-mmlab/mmcv/blob/master/mmcv/parallel/data_parallel.py#L52 will prompt error if
self.device_ids
is falsy.In GPU mode, the following code is executed instead https://github.com/open-mmlab/mmcv/blob/master/mmcv/parallel/data_parallel.py#L67 with no error message.
modifying line 52 to
(*inputs[0], *kwargs[0])
seems to resolve the error with no other issue. Is there a reason why there is difference between line 52 and line 67 ?In addition,
why CPU mode unsqueeze additional dimension ? https://github.com/open-mmlab/mmcv/blob/master/mmcv/parallel/_functions.py#L28
output = output.unsqueeze(0)
The comment mention
But it is not clear how GPU will have addition dimension
The text was updated successfully, but these errors were encountered: