traveller59 / spconv

Spatial Sparse Convolution Library
Apache License 2.0
1.84k stars 362 forks source link

Import Error for spconv-cu117 #665

Open oneya999 opened 9 months ago

oneya999 commented 9 months ago

Hi SpConv author, thanks for your excellent work! When I train my model but there is always an import error after installing spconv :

raceback (most recent call last):
  File "/home/user/IoSI-CP/IoSI-CP/opencood/data_utils/pre_processor/sp_voxel_preprocessor.py", line 24, in __init__
    from spconv.utils import VoxelGeneratorV2 as VoxelGenerator
  File "/home/user/anaconda3/envs/IoSI-CP/lib/python3.8/site-packages/spconv/utils/__init__.py", line 18, in <module>
    from spconv.cppconstants import CPU_ONLY_BUILD
  File "/home/user/anaconda3/envs/IoSI-CP/lib/python3.8/site-packages/spconv/cppconstants.py", line 15, in <module>
    import spconv.core_cc as _ext
ImportError: arg(): could not convert default argument 'workspace: tv::Tensor' in method '<class 'spconv.core_cc.csrc.sparse.convops.gemmops.GemmTunerSimple'>.run_with_tuned_result' into a Python object (type not registered yet?)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "opencood/tools/train.py", line 209, in <module>
    main()
  File "opencood/tools/train.py", line 45, in main
    opencood_train_dataset = build_dataset(hypes, visualize=False, train=True,uni_time_delay=-1)
  File "/home/user/IoSI-CP/IoSI-CP/opencood/data_utils/datasets/__init__.py", line 31, in build_dataset
    dataset = __all__[dataset_name](
  File "/home/user/IoSI-CP/IoSI-CP/opencood/data_utils/datasets/intermediate_fusion_dataset.py", line 52, in __init__
    self.pre_processor = build_preprocessor(params['preprocess'],
  File "/home/user/IoSI-CP/IoSI-CP/opencood/data_utils/pre_processor/__init__.py", line 27, in build_preprocessor
    processor = __all__[process_method_name](
  File "/home/user/IoSI-CP/IoSI-CP/opencood/data_utils/pre_processor/sp_voxel_preprocessor.py", line 27, in __init__
    from spconv.utils import Point2VoxelCPU3d as VoxelGenerator
  File "/home/user/anaconda3/envs/IoSI-CP/lib/python3.8/site-packages/spconv/utils/__init__.py", line 18, in <module>
    from spconv.cppconstants import CPU_ONLY_BUILD
  File "/home/user/anaconda3/envs/IoSI-CP/lib/python3.8/site-packages/spconv/cppconstants.py", line 15, in <module>
    import spconv.core_cc as _ext
ImportError: generic_type: cannot initialize type "ExternalAllocator": an object with that name is already defined

My spconv vresion is spconv-cu117 2.3.6 , torch vrsion is 1.13.0+cu117, I look forward to any suggestions.

kanglang123 commented 7 months ago

Me too.

vehxianfish commented 4 months ago

Based on ReadME. The reason is most likely by cumm and spconv installation question. My solution is to uninstall cumm, spconv and reinstall it.

  1. uninstall spconv
    pip list | grep spconv 
    pip uninstall all-spconv -relative
    pip list | grep cumm
    pip uninstall all-cumm-relative
  2. find match version with your cuda
    pip install spconv-cu{version}
  3. if still not ok, you should try to downgrade spconv version. because in ReadME, it's safe to have different minor cuda version between system and conda (pytorch) in CUDA >= 11.0 because of CUDA Minor Version Compatibility. For example, you can use spconv-cu114 with anaconda version of pytorch cuda 11.1 in a OS with CUDA 11.2 installed.
colorfulandcjy0806 commented 3 months ago

Perhaps everyone can try this. My environment is ubuntu20.04 and cuda is 11.4. Although I tried many methods but found them ineffective, I successfully solved the above problem through pip install spconv-cu102. I hope it is helpful to everyone.😄