RuntimeError: unimplemented data type

Hi, I am very new to pytorch and I met a runtime error when trying to do a multiplication between two tensors as following:

a = torch.nonzero(self.fake[i,0,:,:].data)
b = torch.nonzero(self.real[i, 0, :, :].data)
ab =, b.t())

and the error message is :

Traceback (most recent call last):
  File "", line 32, in xxx
  File "xxxx", line 311, in xxx
  File "xxxx", line 246, in xxx
    ab =, b.t())
RuntimeError: unimplemented data type at xxx\pytorch\torch\lib\thc\generic/

Does someone know what cause this error? Thanks a lot!

What is type(a) and type(b)?

They’re <class ‘torch.cuda.LongTensor’>., b.float().t()) should work.
I’m not sure if this is intentional, but matrix multiplication doesn’t work on cuda long tensors.

The blas libraries that do matrix multiplication only support floating point numbers, so this is intentional. The error message could be better, though, I’ve opened an issue here for that: .

Thanks a lot for your helps, I would transfer them into float tensor.

BTW why are you trying to matrix multiply a and b? From your example, a is a list of indices from self.fake[i,0,:,:].data

I am trying to compute a chamfer distance between two binary map. Reference can be found here: Fastest way to find nearest neighbor for a set of points

1 Like