Thanks to visit codestin.com
Credit goes to github.com

Skip to content

convert output_device at data_parallel from torch.device to index#10189

Closed
weiyangfb wants to merge 1 commit into
pytorch:masterfrom
weiyangfb:parallel_device
Closed

convert output_device at data_parallel from torch.device to index#10189
weiyangfb wants to merge 1 commit into
pytorch:masterfrom
weiyangfb:parallel_device

Conversation

@weiyangfb
Copy link
Copy Markdown
Contributor

@weiyangfb
Copy link
Copy Markdown
Contributor Author

@pytorchbot retest this please

@vishwakftw
Copy link
Copy Markdown
Contributor

I believe there are some instances of the same case in nn/parallel/distributed.py and nn/parallel/distributed_c10d.py. Could those be changed too?

@weiyangfb
Copy link
Copy Markdown
Contributor Author

@vishwakftw I see, I will change them as well

Comment thread test/test_nn.py Outdated
# test output_device
l = nn.Linear(10, 5).float().cuda()
i = Variable(torch.randn(20, 10).float().cuda())
out = dp.data_parallel(l, i, (0, 1), torch.device('cuda'))

This comment was marked as off-topic.

This comment was marked as off-topic.

@weiyangfb weiyangfb added the ready for review (this tag is deprecated) All PRs are ready for review unless they are draft, WIP, or have undismissed requested changes label Aug 14, 2018
Copy link
Copy Markdown
Contributor

@li-roy li-roy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me.

@li-roy
Copy link
Copy Markdown
Contributor

li-roy commented Aug 16, 2018

actually, can we add a test for the other two code paths as well?

Copy link
Copy Markdown
Collaborator

@ssnl ssnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The better fix is to make scatter, gather, parallel_apply, etc. to accept device objects (vs. converting to idx in DP). You can also make device_ids to support device objects this way.

@fmassa
Copy link
Copy Markdown
Member

fmassa commented Aug 28, 2018

ping @weiyangfb on @ssnl suggestion.

@ssnl
Copy link
Copy Markdown
Collaborator

ssnl commented Aug 28, 2018

you can probably use/adapt torch.cuda._get_device_index now to do that after #10833 .

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weiyangfb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weiyangfb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@weiyangfb
Copy link
Copy Markdown
Contributor Author

is this good to go? @ssnl

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weiyangfb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@weiyangfb
Copy link
Copy Markdown
Contributor Author

is this good to go? @ssnl @teng-li @ailzhang

Comment thread torch/nn/parallel/parallel_apply.py Outdated

This comment was marked as off-topic.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weiyangfb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

Comment thread test/test_nn.py Outdated

This comment was marked as off-topic.

Comment thread torch/nn/parallel/data_parallel.py Outdated

This comment was marked as off-topic.

Comment thread torch/nn/parallel/replicate.py Outdated

This comment was marked as off-topic.

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weiyangfb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@weiyangfb
Copy link
Copy Markdown
Contributor Author

@ssnl would you like to take quick pass on this? The updates are separated test function and doc fixes. Thanks!

Copy link
Copy Markdown
Collaborator

@ssnl ssnl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm, but there is one remaining nit to be addressed

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weiyangfb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@weiyangfb
Copy link
Copy Markdown
Contributor Author

@ssnl I see, fixed more places with Device -> torch.device

Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weiyangfb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

…d APIs

1. convert torch.device to device.index in APIs
2. docs fixes
Copy link
Copy Markdown
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

weiyangfb has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

@ezyang ezyang added the merged label Jun 26, 2019
laurentdupin pushed a commit to laurentdupin/pytorch that referenced this pull request Apr 24, 2026
…torch#10189)

Summary:
- fixes pytorch#9984
Pull Request resolved: pytorch#10189

Differential Revision: D9545390

Pulled By: weiyangfb

fbshipit-source-id: 3a6a705437553ba319e9fd4b7f676ff73857a27e
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review (this tag is deprecated) All PRs are ready for review unless they are draft, WIP, or have undismissed requested changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

torch.device and torch.nn.parallel.data_parallel compatibility

9 participants