Conversation
apaszke
reviewed
Mar 5, 2017
| replicas = self.replicate(self.module, self.device_ids) | ||
| scattered = self.scatter(inputs, self.device_ids) | ||
|
|
||
| used_gpus = len(scattered) # The last GPU might not be used. For example, input of size 5, on 4 GPUs |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| for i in self.device_ids | ||
| ) | ||
|
|
||
| gpu_dicts = tuple() |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
| ) | ||
|
|
||
| gpu_dicts = tuple() | ||
| for i in range(used_gpus): |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
apaszke
reviewed
Mar 5, 2017
|
|
||
| used_gpus = len(scattered) # The last GPU might not be used. For example, input of size 4, on 5 GPUs | ||
| gpu_dicts = None | ||
| if kwargs: |
This comment was marked as off-topic.
This comment was marked as off-topic.
Sorry, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When you have an input of dim[0] = 5, and it is sent to DataParallel on 4 GPUs, it is scattered as (2, 2, 1) and GPU-4 is unused.
In this case, the scattering logic of the kwargs scatter is broken, as it does not check for the number of GPUs used, and instead tries to use self.device_ids. This is wrong.
Also, another bug is that it tries to use the values of self.device_ids, assuming that self.device_ids are given in ascending order starting from 0. If they are given as
(1,2,3,0), the incorrect kwargs are sent to the wrong GPU.Fix these corner cases.
cc: @csarofeen