fxia22 / stn.pytorch

pytorch version of spatial transformer networks
Other
589 stars 87 forks source link

error in BilinearSampler.updateOutput: invalid device function #12

Closed yangyi02 closed 7 years ago

yangyi02 commented 7 years ago

I compiled the code and run the test.py, but I got some error message below:

script $ python test.py Variable containing: (0 ,.,.) = 0.8000 0.3000 1.0000 0.5000 0.0000 0.0000 [torch.FloatTensor of size 1x2x3]

(1L, 64L, 128L, 2L) (1L, 2L, 3L) (64L, 64L, 128L, 64L) time: 0.219668865204 (64L, 64L, 128L, 64L) time: 0.432946920395 error in BilinearSampler.updateOutput: invalid device function Traceback (most recent call last): File "test.py", line 48, in out = s(input1, input2) File "/usr/local/lib/python2.7/dist-packages/torch/nn/modules/module.py", line 206, in call result = self.forward(*input, *kwargs) File "stn.pytorch/script/modules/stn.py", line 12, in forward return self.f(input1, input2) File "stn.pytorch/script/functions/stn.py", line 24, in forward my_lib.BilinearSamplerBHWD_updateOutput_cuda(input1, input2, output, self.device_c) File "/usr/local/lib/python2.7/dist-packages/torch/utils/ffi/init.py", line 177, in safe_call result = torch._C._safe_call(args, **kwargs) torch.FatalError: aborting at stn.pytorch/script/src/my_lib_cuda.c:50

I have been able to compile the code by running ./make.sh. The compilation looks well.

I am using cuda 8.0, pytorch 0.1.12.post2, and ubuntu 16.04.

fxia22 commented 7 years ago

Oh, in the test I am assuming you have 4 GPUS, you can change torch.cuda.device() accordingly.

yangyi02 commented 7 years ago

I have simply changed line 44 in test.py from: with torch.cuda.device(3) to: with torch.cuda.device(1)

I have two GPUs. However the error message is still the same.

yangyi02 commented 7 years ago

I find the solution. It's because my GPU is old version.

After I modify -arch=sm_52 to -arch=sm_35 in make.sh, the code has no problem. Thanks.

Similar issues happen in https://github.com/longcw/faster_rcnn_pytorch/issues/2

fxia22 commented 7 years ago

Got it, will add to readme. Thanks.