Skip to content
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

Tensor::device() does not respect Tensor::to_device(...) #62

Closed
jerry73204 opened this issue Jul 9, 2019 · 2 comments
Closed

Tensor::device() does not respect Tensor::to_device(...) #62

jerry73204 opened this issue Jul 9, 2019 · 2 comments

Comments

@jerry73204
Copy link
Contributor

jerry73204 commented Jul 9, 2019

I ran into this issue when I'm working with multi-GPU training. Surprisingly, this test failed unexpectedly. The device() returns Cuda(1) after to_device(Cuda(0)). Suppose it an off-by-1 bug?

use tch::{Tensor, Device};

#[test]
fn test_device() {
    let x = Tensor::from(1).to_device(Device::Cuda(0));
    assert_eq!(x.device(), Device::Cuda(0)); // actually returns Device::Cuda(1)
}
@LaurentMazare
Copy link
Owner

Thanks for catching this, I just pushed a fix for it (and will add some test although it won't run on CI as there are no gpus there).

@jerry73204
Copy link
Contributor Author

Many thanks.

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

No branches or pull requests

2 participants