Skip to content

Fix GPU device placement when calling tensor.cuda()#624

Merged
neerajprad merged 5 commits intodevfrom
fix-cuda-device
Dec 15, 2017
Merged

Fix GPU device placement when calling tensor.cuda()#624
neerajprad merged 5 commits intodevfrom
fix-cuda-device

Conversation

@fritzo
Copy link
Copy Markdown
Member

@fritzo fritzo commented Dec 13, 2017

Fixes #623
Suggested by @apaszke

This also fixes the shape of distributions.Delta.enumerate_support(), which was returning an element rather than a singleton tensor containing that element (to see the difference, consider for x in dist.enumerate_support(): ...).

Testing

I tested that this runs on a single GPU but I have not tested on a multi-GPU system.

@fritzo fritzo added the bug label Dec 13, 2017
@fritzo fritzo requested a review from neerajprad December 13, 2017 02:47
Comment thread tests/infer/mcmc/test_mcmc.py Outdated
sample_std = torch.std(torch.stack(samples), 0)
assert_equal(sample_mean.data, torch.Tensor([0.0]), prec=5e-2)
assert_equal(sample_std.data, torch.Tensor([1.0]), prec=5e-2)
assert_equal(sample_mean.data, torch.Tensor([0.0]), prec=0.1)
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I had to loosen this tolerance due to flakiness. I assume the CUDA rng state is slightly different.

:rtype: torch.autograd.Variable.
"""
return Variable(self.v.data)
return Variable(self.v.data.unsqueeze(0))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for this fix.

@neerajprad
Copy link
Copy Markdown
Member

Not sure what's wrong, but all the builds are returning:

The log length has exceeded the limit of 4 MB (this usually means that the test suite is raising the same exception over and over).

@neerajprad
Copy link
Copy Markdown
Member

Can we remove #627 from this PR, to get this merged earlier?

@fritzo
Copy link
Copy Markdown
Member Author

fritzo commented Dec 14, 2017

Can we remove #627 from this PR

This PR relies on newer functionality of torch.arange() that is only available in 0.4. I'll see how difficult it is to use an older invocation of torch.arange()...

@neerajprad
Copy link
Copy Markdown
Member

This PR relies on newer functionality of torch.arange() that is only available in 0.4.

If there is a lot of effort involved, we could just wait for the smaller wheel to be available.

@fritzo
Copy link
Copy Markdown
Member Author

fritzo commented Dec 15, 2017

@neerajprad Looks like this is ready to merge

@neerajprad neerajprad merged commit 87eb2a8 into dev Dec 15, 2017
@fritzo fritzo deleted the fix-cuda-device branch December 18, 2017 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix GPU placement when calling tensor.cuda()

2 participants