Skip to content

Conversation

@yf225
Copy link
Contributor

@yf225 yf225 commented Oct 22, 2018

Currently, a = 1 - torch.tensor([1]).to('cuda:1') puts a in cuda:1 but reports a.device as cuda:0 which is incorrect, and it causes illegal memory access error when trying to access a's memory (e.g. when printing). This PR fixes the error.

Fixes #10850.

@yf225 yf225 requested a review from colesbury October 22, 2018 23:23
{"__mul__", (PyCFunction)THPVariable_mul, METH_VARARGS | METH_KEYWORDS, NULL},
{"__imul__", (PyCFunction)THPVariable_mul_, METH_VARARGS | METH_KEYWORDS, NULL},
{"__sub__", (PyCFunction)THPVariable_sub, METH_VARARGS | METH_KEYWORDS, NULL},
{"__rsub__", (PyCFunction)THPVariable_sub, METH_VARARGS | METH_KEYWORDS, NULL},

This comment was marked as off-topic.

@yf225 yf225 changed the title Fix "CUDA Tensor __rsub__ breaks when device is not 0" [WIP] Fix "CUDA Tensor __rsub__ breaks when device is not 0" Oct 22, 2018
@yf225 yf225 changed the title [WIP] Fix "CUDA Tensor __rsub__ breaks when device is not 0" Fix "CUDA Tensor __rsub__ breaks when device is not 0" Oct 23, 2018
@yf225 yf225 force-pushed the rsub_fix branch 3 times, most recently from da2b75f to dfe1f4d Compare October 23, 2018 20:48
Copy link
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.

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

Copy link
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.

yf225 is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

zdevito pushed a commit to zdevito/ATen that referenced this pull request Oct 31, 2018
Summary:
Currently, `a = 1 - torch.tensor([1]).to('cuda:1')` puts `a` in `cuda:1` but reports `a.device` as `cuda:0` which is incorrect, and it causes illegal memory access error when trying to access `a`'s memory (e.g. when printing). This PR fixes the error.

Fixes pytorch/pytorch#10850.
Pull Request resolved: pytorch/pytorch#12956

Differential Revision: D12835992

Pulled By: yf225

fbshipit-source-id: 5737703d2012b14fd00a71dafeedebd8230a0b04
@ezyang ezyang added the merged label Jun 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

CUDA Tensor __rsub__ breaks when device is not 0

4 participants