ClementPinard / Pytorch-Correlation-extension

Custom implementation of Corrleation Module
MIT License
413 stars 77 forks source link

Successfully installed, but unable to import in the code. #108

Closed 22236 closed 6 months ago

22236 commented 6 months ago

In the terminal, you can import, but you get a strange error in the code. 微信图片_20240312230216 In the code: File "/home//////.py", line 282, in init from spatial_correlation_sampler import SpatialCorrelationSampler File "/home//anaconda3/envs//lib/python3.9/site-packages/spatial_correlation_sampler-0.4.0-py3.9-linux-x86_64.egg/spatial_correlation_sampler/init.py", line 1, in from .spatial_correlation_sampler import SpatialCorrelationSampler, spatial_correlation_sample File "/home//anaconda3/envs//lib/python3.9/site-packages/spatial_correlation_sampler-0.4.0-py3.9-linux-x86_64.egg/spatial_correlation_sampler/spatial_correlation_sampler.py", line 7, in import spatial_correlation_sampler_backend as correlation ImportError: /home//anaconda3/envs//lib/python3.9/site-packages/spatial_correlation_sampler-0.4.0-py3.9-linux-x86_64.egg/spatial_correlation_sampler_backend.cpython-39-x86_64-linux-gnu.so: undefined symbol: _ZNSt15__exception_ptr13exception_ptr9_M_addrefEv

My version: pytorch1.10.0+cu113. To install, use setup.py on the server in the installation package.

ClementPinard commented 6 months ago

Hi, this package is only compatible with torch > 2.1.0 if you need backward compatibility, you can try a former version, like 0.3.0 which was out in 2020.

You can also try by installing with pip and the --no-build-isolation option

pip install --no-build-isolation spatial-correlation-sampler

that way, it will try to build against your pytorch installation rather than the last built pytorch package

22236 commented 6 months ago

Thank you for your quick response. I installed version 0.3.0 and imported the package path using

import sys sys.path.append(path/to/spatial-correlation-sampler)

in case my code couldn't find it.

It's all right now. Thanks again.

22236 commented 6 months ago

Hello, my error has not been completely resolved. On the latest version of vscode, once I referenced this package, I couldn't use the debug feature and had to run it directly. But sometimes running it directly throws an error. Now I download vscode 2019 (1.41.1) and still get an error. Not only can't I use the debug feature at the moment, it also gives me an error. (Different versions of vscode will give errors on both computers)

22236 commented 6 months ago

Hello, my error has not been completely resolved. On the latest version of vscode, once I referenced this package, I couldn't use the debug feature and had to run it directly. But sometimes running it directly throws an error. Now I'm using cuda11.8, installing pytorch2.1.0, spatial_correlation_sampler0.5.0, still getting errors: 微信截图_20240408232612