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

Exception has occurred: TypeError only integer tensors of a single element can be converted to an index #37

Closed
chronbird opened this issue Jun 28, 2020 · 2 comments

Comments

@chronbird
Copy link

Hi @chrischoy ,

Thanks for the great work! When I am trying training semantic segmentation on ScanNet, I encounter the following exception:

Traceback (most recent call last): File "/home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/runpy.py", line 194, in _run_module_as_main return _run_code(code, main_globals, None, File "/home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/runpy.py", line 87, in _run_code exec(code, run_globals) File "/home/chronbird/SpatioTemporalSegmentation/main.py", line 156, in <module> main() File "/home/chronbird/SpatioTemporalSegmentation/main.py", line 149, in main train(model, train_data_loader, val_data_loader, config) File "/home/chronbird/SpatioTemporalSegmentation/lib/train.py", line 91, in train soutput = model(*inputs) File "/home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/site-packages/torch/nn/modules/module.py", line 550, in __call__ result = self.forward(*input, **kwargs) File "/home/chronbird/SpatioTemporalSegmentation/models/res16unet.py", line 204, in forward out_b1p2 = self.block1(out) File "/home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/site-packages/torch/nn/modules/module.py", line 550, in __call__ result = self.forward(*input, **kwargs) File "/home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/site-packages/torch/nn/modules/container.py", line 100, in forward input = module(input) File "/home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/site-packages/torch/nn/modules/module.py", line 550, in __call__ result = self.forward(*input, **kwargs) File "/home/chronbird/SpatioTemporalSegmentation/models/modules/resnet_block.py", line 42, in forward out = self.conv1(x) File "/home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/site-packages/torch/nn/modules/module.py", line 550, in __call__ result = self.forward(*input, **kwargs) File "/home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/site-packages/MinkowskiEngine/MinkowskiConvolution.py", line 263, in forward self.kernel_generator.get_kernel(input.tensor_stride, self.is_transpose) File "/home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/site-packages/MinkowskiEngine/Common.py", line 347, in get_kernel self.cache[tuple(tensor_stride)] = convert_region_type( File "/home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/site-packages/MinkowskiEngine/Common.py", line 272, in convert_region_type region_offset = torch.IntTensor(region_offset) TypeError: only integer tensors of a single element can be converted to an index

Then I check about the input of self.block1, it is
SparseTensor( Coords=tensor([[ 1, 74, 8, 150], [ 1, 70, 0, 192], [ 8, -190, 350, 82], ..., [ 1, 240, 6, 192], [ 5, 380, -82, 136], [ 6, 70, -68, 110]], dtype=torch.int32) Feats=tensor([[2.4673, 1.2257, 2.8942, ..., 0.0000, 2.3988, 0.0000], [0.5576, 0.0000, 0.0000, ..., 0.9546, 0.0000, 0.1357], [0.2138, 0.1608, 0.0000, ..., 0.0000, 0.3920, 0.0000], ..., [0.0000, 0.0000, 0.0000, ..., 0.0000, 0.0000, 0.4807], [0.0000, 0.0366, 0.0000, ..., 0.5666, 0.0000, 1.0899], [0.0000, 1.6132, 0.0000, ..., 0.1976, 0.0000, 1.4563]], device='cuda:0', grad_fn=<ReluBackward1>) coords_key=< CoordsKey, key: 16908437251554604741, tensor_stride: [2, 2, 2, ��] in dimension: 3 > tensor_stride=[2, 2, 2] coords_man=< CoordsManager Number of Coordinate Maps: 2 Coordinate Map Key: 16908437251554604741, Size: 323293 Coordinate Map Key: 15034981587763204738, Size: 821840 Number of Kernel Maps: 2 Kernel In-Out Map Key: 1762388836632698508, Size: 821840 Kernel In-Out Map Key: 13453830109827794797, Size: 7072854 > spatial dimension=3)

and self.block1
Sequential( (0): BasicBlock( (conv1): MinkowskiConvolution(in=32, out=32, region_type=RegionType.HYBRID, kernel_volume=27, stride=[1, 1, 1], dilation=[1, 1, 1]) (norm1): MinkowskiBatchNorm(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (conv2): MinkowskiConvolution(in=32, out=32, region_type=RegionType.HYBRID, kernel_volume=27, stride=[1, 1, 1], dilation=[1, 1, 1]) (norm2): MinkowskiBatchNorm(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (relu): MinkowskiReLU() ) (1): BasicBlock( (conv1): MinkowskiConvolution(in=32, out=32, region_type=RegionType.HYBRID, kernel_volume=27, stride=[1, 1, 1], dilation=[1, 1, 1]) (norm1): MinkowskiBatchNorm(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (conv2): MinkowskiConvolution(in=32, out=32, region_type=RegionType.HYBRID, kernel_volume=27, stride=[1, 1, 1], dilation=[1, 1, 1]) (norm2): MinkowskiBatchNorm(32, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True) (relu): MinkowskiReLU() ) )

I am using Pytorch 1.5.1 and the latest MinkowskiEngine built from source. Could you please help me check what might possibly cause the error? Thanks in advance.

@chronbird
Copy link
Author

found solution at /home/chronbird/anaconda3/envs/pointcloud/lib/python3.8/site-packages/MinkowskiEngine/Common.py, where each
(tensor_stride[d] / up_stride[d])
can be modified as
(tensor_stride[d] / up_stride[d]).int()
then the exception will disappear.

@chrischoy
Copy link
Owner

Thanks for reporting the issue. I'll fix this on the next version.

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