-
Notifications
You must be signed in to change notification settings - Fork 26.3k
Description
Issue description
After sampling from a Beta distribution using CUDA tensors, topk returns incorrect indeces and values. First transfering the samples to the cpu fixes the issue.
Code example
`
import torch
from torch.distributions.beta import Beta
zeros = torch.zeros(10).cuda()
alpha = zeros + 1.6
beta = zeros + 1.5
sample = Beta(alpha, beta).sample()
tensor([0.7466, 0.6613, 0.1345, 0.7948, 0.3974, 0.4831, 0.0791, 0.0623, 0.7264, 0.0677], device='cuda:0')
sample.topk(5)
(tensor([0.8655, 0.7948, 0.7466, 0.6613, 0.6026], device='cuda:0'), tensor([5, 6, 0, 2, 9], device='cuda:0'))
sample.cpu().topk(5)
(tensor([0.7948, 0.7466, 0.7264, 0.6613, 0.4831]), tensor([3, 0, 8, 1, 5]))
`
System Info
PyTorch version: 0.5.0a0+1597fc5
Is debug build: No
CUDA used to build PyTorch: 9.2.148
OS: Ubuntu 18.04 LTS
GCC version: (Ubuntu 7.3.0-16ubuntu3) 7.3.0
CMake version: version 3.11.1
Python version: 3.6
Is CUDA available: Yes
CUDA runtime version: 9.2.148
GPU models and configuration: GPU 0: GeForce GTX 1080 Ti
Nvidia driver version: 396.37
cuDNN version: Probably one of the following:
/usr/local/cuda-9.1/lib64/libcudnn.so
/usr/local/cuda-9.1/lib64/libcudnn.so.7
/usr/local/cuda-9.1/lib64/libcudnn.so.7.1.1
/usr/local/cuda-9.1/lib64/libcudnn_static.a
Versions of relevant libraries:
[pip3] numpy (1.14.1)
[pip3] numpydoc (0.7.0)
[conda] magma-cuda91 2.3.0 1 pytorch
[conda] torch 0.5.0a0+1597fc5