xinge008 / Cylinder3D

Rank 1st in the leaderboard of SemanticKITTI semantic segmentation (both single-scan and multi-scan) (Nov. 2020) (CVPR2021 Oral)
Apache License 2.0
859 stars 180 forks source link

[Help Wanted] AttributeError: module 'spconv' has no attribute 'SubMConv3d' #90

Closed adrianezquerro closed 3 years ago

adrianezquerro commented 3 years ago

Hi everyone!

I am trying to run this project, and I'm locked. I try to run the project after installing all the necessary modules, which I will indicate later, and I only receive this error. I have tried to change the version of cuda, (11.1, 11.4, 11.5), install drivers, run from ubuntu, and I always get this error:

C:\Users\v\Desktop\Cilindro\Cylinder3D>py demo_folder.py --demo-folder . --save-folder . Namespace(config_path='config/semantickitti.yaml', demo_folder='.', demo_label_folder='', save_folder='.') [480 360 32] Traceback (most recent call last): File "demo_folder.py", line 151, in main(args) File "demo_folder.py", line 83, in main my_model = model_builder.build(model_config) File "C:\Users\v\Desktop\Cilindro\Cylinder3D\builder\model_builder.py", line 19, in build cylinder_3d_spconv_seg = Asymm_3d_spconv( File "C:\Users\v\Desktop\Cilindro\Cylinder3D\network\segmentator_3d_asymm_spconv.py", line 265, in init self.downCntx = ResContextBlock(num_input_features, init_size, indice_key="pre") File "C:\Users\v\Desktop\Cilindro\Cylinder3D\network\segmentator_3d_asymm_spconv.py", line 49, in init self.conv1 = conv1x3(in_filters, out_filters, indice_key=indice_key + "bef") File "C:\Users\v\Desktop\Cilindro\Cylinder3D\network\segmentator_3d_asymm_spconv.py", line 17, in conv1x3 return spconv.SubMConv3d(in_planes, out_planes, kernel_size=(1, 3, 3), stride=stride, AttributeError: module 'spconv' has no attribute 'SubMConv3d'`

I am using python 3.8.0, and a virtual environment Requirements; Yaml 6.0 Cython 0.29.24 Pytorch 1.8.1+cu111 Torch-scatter 2.0.9 Spconv 2.0.2-cu114 nuscenes-devkit 1.1.9

I greatly appreciate if someone can contact me and help me with this error.

xinge008 commented 3 years ago

I do not test with other version of spconv. Can you try with spconv==1.2.1?

adrianezquerro commented 3 years ago

I do not test with other version of spconv. Can you try with spconv==1.2.1?

Yeah, running 1.2.1 solve the problem.

Thank you

ruanych commented 2 years ago

The problem is that in new versions of spconv, some modules are moved from the spconv. path to spconv.pytorch.conv., such as SubMConv3d, SparseConv3d, etc.

So, a new solution: Change spconv.SubMConv3d to spconv.pytorch.conv.SubMConv3d, SparseConv3d and other modules are similar. Of course, import spconv also needs to be changed to import spconv.pytorch.conv

I tested it successfully in version 2.1.2.

More detail: https://github.com/traveller59/spconv/blob/master/docs/SPCONV_2_BREAKING_CHANGEs.md

ZhouYC-X commented 2 years ago

Sorry to bother @Ryyyc . I encountered an assertion error(assert my_model_dict[k].shape == value.shape') when I use 2.1.2. I tried to print the shape info as print("model shape:{}, pre shape:{}".format(str(my_model_dict[k].shape), str(value.shape)))

The result is: model shape:torch.Size([32, 1, 3, 3, 32]), pre shape:torch.Size([1, 3, 3, 32, 32])

I tried to modified as 'my_model_dict[k] = my_model_dict[k].transpose(0, 1).transpose(1, 2).transpose(2, 3).transpose(3, 4)' however, some sample still produce error as: model shape:torch.Size([3, 3, 3, 512, 256]), pre shape:torch.Size([3, 3, 3, 512, 512])

I want to know whether it is caused by the spconv version or the Cylinder. looking forward to your reply, thanks again

ruanych commented 2 years ago

Sorry to bother @Ryyyc . I encountered an assertion error(assert my_model_dict[k].shape == value.shape') when I use 2.1.2. I tried to print the shape info as print("model shape:{}, pre shape:{}".format(str(my_model_dict[k].shape), str(value.shape)))

The result is: model shape:torch.Size([32, 1, 3, 3, 32]), pre shape:torch.Size([1, 3, 3, 32, 32])

I tried to modified as 'my_model_dict[k] = my_model_dict[k].transpose(0, 1).transpose(1, 2).transpose(2, 3).transpose(3, 4)' however, some sample still produce error as: model shape:torch.Size([3, 3, 3, 512, 256]), pre shape:torch.Size([3, 3, 3, 512, 512])

I want to know whether it is caused by the spconv version or the Cylinder. looking forward to your reply, thanks again

@zhouyuchen01 From your description, I'm guessing you're migrating model weights from spconv1.x to spconv2.x. I think you can refer to the change in spconv weight layout at

https://github.com/traveller59/spconv/blob/master/docs/SPCONV_2_BREAKING_CHANGEs.md

weight layout has been changed to RSKC (native algorithm) or KRSC (implicit gemm), no longer RSCK (spconv 1.x). RS is kernel size, C is input channel, K is output channel.

Of course, first you should make sure that your model hyperparameter settings are the same the pre-trained model, and secondly, you should only change the weights of the spconv module, and should not include other modules.

ZhouYC-X commented 2 years ago

@Ryyyc Thanks for your suggestion as well as your kind help.

Vonct commented 8 months ago

@ZhouYC-X sorry to bother. Have you successfully reproduce on spconv2.x, using the given weight?