ClementPinard / Pytorch-Correlation-extension

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

Fail to use "python setup.py install" to install spatial-correlation-sampler #98

Open JxinYUN opened 1 year ago

JxinYUN commented 1 year ago

I had cloned “https://github.com/ClementPinard/Pytorch-Correlation-extension” and used the commend: python setup.py install, but there are something worth. I don't know how to tackle that. Help me please.

cuda version: 11.2 pytorch version: 2.0.1 python version: 3.11.4 ubuntu version: 20.04

The follow is the error statement: No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda-11.0' running install /home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/cmd.py:66: SetuptoolsDeprecationWarning: setup.py install is deprecated. !!

    ********************************************************************************
    Please avoid running ``setup.py`` directly.
    Instead, use pypa/build, pypa/installer or other
    standards-based tools.

    See https://blog.ganssle.io/articles/2021/10/setup-py-deprecated.html for details.
    ********************************************************************************

!! self.initialize_options() /home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/cmd.py:66: EasyInstallDeprecationWarning: easy_install command is deprecated. !!

    ********************************************************************************
    Please avoid running ``setup.py`` and ``easy_install``.
    Instead, use pypa/build, pypa/installer or other
    standards-based tools.

    See https://github.com/pypa/setuptools/issues/917 for details.
    ********************************************************************************

!! self.initialize_options() running bdist_egg running egg_info writing Correlation_Module/spatial_correlation_sampler.egg-info/PKG-INFO writing dependency_links to Correlation_Module/spatial_correlation_sampler.egg-info/dependency_links.txt writing requirements to Correlation_Module/spatial_correlation_sampler.egg-info/requires.txt writing top-level names to Correlation_Module/spatial_correlation_sampler.egg-info/top_level.txt reading manifest file 'Correlation_Module/spatial_correlation_sampler.egg-info/SOURCES.txt' adding license file 'LICENSE' writing manifest file 'Correlation_Module/spatial_correlation_sampler.egg-info/SOURCES.txt' installing library code to build/bdist.linux-x86_64/egg running install_lib running build_py running build_ext Traceback (most recent call last): File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/Pytorch-Correlation-extension-master/Pytorch-Correlation-extension-master/setup.py", line 69, in launch_setup() File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/Pytorch-Correlation-extension-master/Pytorch-Correlation-extension-master/setup.py", line 37, in launch_setup setup( File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/init.py", line 107, in setup return distutils.core.setup(**attrs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 185, in setup return run_commands(dist) ^^^^^^^^^^^^^^^^^^ File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/core.py", line 201, in run_commands dist.run_commands() File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands self.run_command(cmd) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/command/install.py", line 80, in run self.do_egg_install() File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/command/install.py", line 129, in do_egg_install self.run_command('bdist_egg') File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command self.distribution.run_command(command) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/command/bdist_egg.py", line 164, in run cmd = self.call_command('install_lib', warn_dir=0) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/command/bdist_egg.py", line 150, in call_command self.run_command(cmdname) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command self.distribution.run_command(command) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/command/install_lib.py", line 11, in run self.build() File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/command/install_lib.py", line 111, in build self.run_command('build_ext') File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command self.distribution.run_command(command) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/dist.py", line 1234, in run_command super().run_command(command) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/dist.py", line 988, in run_command cmd_obj.run() File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/command/build_ext.py", line 84, in run _build_ext.run(self) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/setuptools/_distutils/command/build_ext.py", line 345, in run self.build_extensions() File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 499, in build_extensions _check_cuda_version(compiler_name, compiler_version) File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/torch/utils/cpp_extension.py", line 383, in _check_cuda_version torch_cuda_version = packaging.version.parse(torch.version.cuda) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/pkg_resources/_vendor/packaging/version.py", line 52, in parse return Version(version) ^^^^^^^^^^^^^^^^ File "/home/xiaojianxin/anaconda3/envs/depth_warehouse_estimation/lib/python3.11/site-packages/pkg_resources/_vendor/packaging/version.py", line 196, in init match = self._regex.search(version) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ TypeError: expected string or bytes-like object, got 'NoneType'

ClementPinard commented 1 year ago

cuda version: 11.2

No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda-11.0'

Looks like your problem is that the compiler points to the wrong cuda version.

Have you set the environment variable ENV and LD_LIBRARY_PATH ?

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#environment-setup

JxinYUN commented 1 year ago

cuda version: 11.2

No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda-11.0'

Looks like your problem is that the compiler points to the wrong cuda version.

Have you set the environment variable ENV and LD_LIBRARY_PATH ?

https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#environment-setup

Yes, the reason is the incompatible version of CUDA. I use "match = self._regex.search(str(version))" to replace "match = self._regex.search(version)" and then reinstall my torch that version is compatible with my CUDA. Finally, I install spatial-correlation-sampler successfully! Thanks.

Wei-Wu233 commented 11 months ago

cuda version: 11.2

No CUDA runtime is found, using CUDA_HOME='/usr/local/cuda-11.0'

Looks like your problem is that the compiler points to the wrong cuda version. Have you set the environment variable ENV and LD_LIBRARY_PATH ? https://docs.nvidia.com/cuda/cuda-installation-guide-linux/index.html#environment-setup

Yes, the reason is the incompatible version of CUDA. I use "match = self._regex.search(str(version))" to replace "match = self._regex.search(version)" and then reinstall my torch that version is compatible with my CUDA. Finally, I install spatial-correlation-sampler successfully! Thanks.

I also encountered this problem, the main reason is that the version of cuda and torch do not match, but after I changed the version of torch, I still have the following problem: (fsam) E:\code\Pytorch-Correlation-extension-master>pip install spatial-correlation-sampler Collecting spatial-correlation-sampler Using cached spatial_correlation_sampler-0.4.0.tar.gz (9.3 kB) Preparing metadata (setup.py) ... done Requirement already satisfied: torch>=1.1 in d:\programdata\anaconda\envs\fsam\lib\site-packages (from spatial-correlation-sampler) (1.12.1+cu113) Requirement already satisfied: numpy in d:\programdata\anaconda\envs\fsam\lib\site-packages (from spatial-correlation-sampler) (1.26.1) Requirement already satisfied: typing-extensions in d:\programdata\anaconda\envs\fsam\lib\site-packages (from torch>=1.1->spatial-correlation-sampler) (4.8.0) Building wheels for collected packages: spatial-correlation-sampler Building wheel for spatial-correlation-sampler (setup.py) ... error error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [22 lines of output] running bdist_wheel D:\ProgramData\anaconda\envs\fsam\lib\site-packages\torch\utils\cpp_extension.py:411: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend. warnings.warn(msg.format('we could not find ninja.')) running build running build_py creating build creating build\lib.win-amd64-cpython-39 creating build\lib.win-amd64-cpython-39\spatial_correlation_sampler copying Correlation_Module\spatial_correlation_sampler\spatial_correlation_sampler.py -> build\lib.win-amd64-cpython-39\spatial_correlation_sampler copying Correlation_Module\spatial_correlation_sampler__init__.py -> build\lib.win-amd64-cpython-39\spatial_correlation_sampler running build_ext D:\ProgramData\anaconda\envs\fsam\lib\site-packages\torch\utils\cpp_extension.py:346: UserWarning: Error checking compiler version for cl: [WinError 2] 系统找不到指定的文件。 warnings.warn(f'Error checking compiler version for {compiler}: {error}') building 'spatial_correlation_sampler_backend' extension creating build\temp.win-amd64-cpython-39 creating build\temp.win-amd64-cpython-39\Release creating build\temp.win-amd64-cpython-39\Release\Correlation_Module "D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe" /c /nologo /O2 /W3 /GL /DNDEBUG /MD -DUSE_CUDA -ID:\ProgramData\anaconda\envs\fsam\lib\site-packages\torch\include -ID:\ProgramData\anaconda\envs\fsam\lib\site-packages\torch\include\torch\csrc\api\include -ID:\ProgramData\anaconda\envs\fsam\lib\site-packages\torch\include\TH -ID:\ProgramData\anaconda\envs\fsam\lib\site-packages\torch\include\THC "-IC:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.3\include" -ID:\ProgramData\anaconda\envs\fsam\include -ID:\ProgramData\anaconda\envs\fsam\Include "-ID:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\ATLMFC\include" "-ID:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include" /EHsc /TpCorrelation_Module\correlation.cpp /Fobuild\temp.win-amd64-cpython-39\Release\Correlation_Module\correlation.obj /MD /wd4819 /wd4251 /wd4244 /wd4267 /wd4275 /wd4018 /wd4190 /EHsc -fopenmp -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=spatial_correlation_sampler_backend -D_GLIBCXX_USE_CXX11_ABI=0 cl: 命令行 warning D9002 :忽略未知选项“-fopenmp” correlation.cpp D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstddef(12): fatal error C1083: 无法打开包括文件: “stddef.h”: No such file or directory error: command 'D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\bin\HostX86\x64\cl.exe' failed with exit code 2 [end of output]

note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for spatial-correlation-sampler Running setup.py clean for spatial-correlation-sampler Failed to build spatial-correlation-sampler ERROR: Could not build wheels for spatial-correlation-sampler, which is required to install pyproject.toml-based projects

ClementPinard commented 6 months ago

D:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.29.30133\include\cstddef(12): fatal error C1083: 无法打开包括文件: “stddef.h”: No such file or directory

Looks like a microsoft + visual code specific error where it cannot file some standard header file. Is your problem fixed now ?