NVIDIA / MinkowskiEngine

Minkowski Engine is an auto-diff neural network library for high-dimensional sparse tensors
https://nvidia.github.io/MinkowskiEngine
Other
2.48k stars 367 forks source link

fixed bug of cuda cpu mismatch #319

Closed ekomurcu closed 3 years ago

ekomurcu commented 3 years ago

Hi,

When I called dense() function to convert sparse tensor back to dense tensor, I got this error: RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

I think the problem comes from the local variable of tensor_stride which should be initialised at the device that is being used. After changing these two lines, I could train my network. Hope this helps.

Best

ethanweber commented 3 years ago

I have a similar issue with calling .sparse() with RuntimeError: ... assertion (at::cuda::check_device({rows, cols, mat2})) failed. All inputs must be on the same device. This is occurring in MinkowskiTensorField.py at this line. Thanks.

loiccordone commented 3 years ago

Hello, the error still occurs when a min_coordinate is passed as a parameter. It must be of type "torch.IntTensor" due to the first assert.

Adding min_coordinate = min_coordinate.to(self.device) line 512 after the else: fix the problem for the 'dense' function.