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

Three months ago, I can use the pip command to compile this, but now it's not working. #112

Open
Chuck-Xu opened this issue May 18, 2024 · 2 comments

Comments

@Chuck-Xu
Copy link

Chuck-Xu commented May 18, 2024

Three months ago, I used this 'pip install spatial-correlation-sampler' in cuda 11.6 perfectly.
Now, after I create a new conda env which includes cuda11.8, pytorch 2.1. Then, I use the pip command, it will prompt an error:
Collecting spatial-correlation-sampler
Using cached https://mirrors.aliyun.com/pypi/packages/66/dd/a0caccedffdbe27c94851eb1faba5d61c86aacf161005580249550dd969b/spatial_correlation_sampler-0.5.0.tar.gz (9.8 kB)
Installing build dependencies ... done
Getting requirements to build wheel ... done
Installing backend dependencies ... done
Preparing metadata (pyproject.toml) ... done
Requirement already satisfied: torch>=1.1 in ./miniconda3/envs/fewShot/lib/python3.8/site-packages (from spatial-correlation-sampler) (2.1.0)
Requirement already satisfied: numpy in ./miniconda3/envs/fewShot/lib/python3.8/site-packages (from spatial-correlation-sampler) (1.24.1)
Requirement already satisfied: filelock in ./miniconda3/envs/fewShot/lib/python3.8/site-packages (from torch>=1.1->spatial-correlation-sampler) (3.13.1)
Requirement already satisfied: typing-extensions in ./miniconda3/envs/fewShot/lib/python3.8/site-packages (from torch>=1.1->spatial-correlation-sampler) (4.11.0)
Requirement already satisfied: sympy in ./miniconda3/envs/fewShot/lib/python3.8/site-packages (from torch>=1.1->spatial-correlation-sampler) (1.12)
Requirement already satisfied: networkx in ./miniconda3/envs/fewShot/lib/python3.8/site-packages (from torch>=1.1->spatial-correlation-sampler) (3.0)
Requirement already satisfied: jinja2 in ./miniconda3/envs/fewShot/lib/python3.8/site-packages (from torch>=1.1->spatial-correlation-sampler) (3.1.3)
Requirement already satisfied: fsspec in ./miniconda3/envs/fewShot/lib/python3.8/site-packages (from torch>=1.1->spatial-correlation-sampler) (2024.2.0)
Requirement already satisfied: MarkupSafe>=2.0 in ./miniconda3/envs/fewShot/lib/python3.8/site-packages (from jinja2->torch>=1.1->spatial-correlation-sampler) (2.1.3)
Requirement already satisfied: mpmath>=0.19 in ./miniconda3/envs/fewShot/lib/python3.8/site-packages (from sympy->torch>=1.1->spatial-correlation-sampler) (1.3.0)
Building wheels for collected packages: spatial-correlation-sampler
Building wheel for spatial-correlation-sampler (pyproject.toml) ... error
error: subprocess-exited-with-error

× Building wheel for spatial-correlation-sampler (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [68 lines of output]
running bdist_wheel
running build
running build_py
creating build
creating build/lib.linux-x86_64-cpython-38
creating build/lib.linux-x86_64-cpython-38/spatial_correlation_sampler
copying Correlation_Module/spatial_correlation_sampler/spatial_correlation_sampler.py -> build/lib.linux-x86_64-cpython-38/spatial_correlation_sampler
copying Correlation_Module/spatial_correlation_sampler/init.py -> build/lib.linux-x86_64-cpython-38/spatial_correlation_sampler
running build_ext
/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/torch/utils/cpp_extension.py:499: 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.'))
Traceback (most recent call last):
File "/home/xuchengcheng/miniconda3/envs/fewShot/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 353, in
main()
File "/home/xuchengcheng/miniconda3/envs/fewShot/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 335, in main
json_out['return_val'] = hook(**hook_input['kwargs'])
File "/home/xuchengcheng/miniconda3/envs/fewShot/lib/python3.8/site-packages/pip/_vendor/pyproject_hooks/_in_process/_in_process.py", line 251, in build_wheel
return _build_backend().build_wheel(wheel_directory, config_settings,
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 410, in build_wheel
return self._build_with_temp_dir(
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 395, in _build_with_temp_dir
self.run_setup()
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 487, in run_setup
super().run_setup(setup_script=setup_script)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 311, in run_setup
exec(code, locals())
File "", line 69, in
File "", line 37, in launch_setup
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/init.py", line 104, in setup
return distutils.core.setup(**attrs)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 184, in setup
return run_commands(dist)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/_distutils/core.py", line 200, in run_commands
dist.run_commands()
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
self.run_command(cmd)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 967, in run_command
super().run_command(command)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-qykojga5/normal/lib/python3.8/site-packages/wheel/bdist_wheel.py", line 368, in run
self.run_command("build")
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 967, in run_command
super().run_command(command)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build.py", line 132, in run
self.run_command(cmd_name)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/_distutils/cmd.py", line 316, in run_command
self.distribution.run_command(command)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/dist.py", line 967, in run_command
super().run_command(command)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 91, in run
_build_ext.run(self)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/setuptools/_distutils/command/build_ext.py", line 359, in run
self.build_extensions()
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 522, in build_extensions
_check_cuda_version(compiler_name, compiler_version)
File "/tmp/pip-build-env-qykojga5/overlay/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 417, in _check_cuda_version
raise RuntimeError(CUDA_MISMATCH_MESSAGE.format(cuda_str_version, torch.version.cuda))
RuntimeError:
The detected CUDA version (11.8) mismatches the version that was used to compile
PyTorch (12.1). Please make sure to use the same CUDA versions.
[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
Failed to build spatial-correlation-sampler
ERROR: Could not build wheels for spatial-correlation-sampler, which is required to install pyproject.toml-based projects

Is there anything wrong with my experimental environment?Hoping the owner can answer my doubts, thanks!

@ClementPinard
Copy link
Owner

Hi, by default, this will build the package with an isolated package, with the last version of pytorch (the one you would get by calling pip install torch . If your pytorch version differs, you now need to use the --no-build-isolation option so that it gets built within your environment with the right pytorch (and cuda) version

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

This is because new pip build scripts are now required to run within a dedicated virtual environment. See related discussion for xformers : facebookresearch/xformers#940 (comment)

@nilonana
Copy link

I met the same problem "The detected CUDA version (12.4) mismatches the version that was used to compile
PyTorch (11.7). ". I used conda install cudatoolkit==11.7 to try to install the suitable version, and I found cuda-nvcc=12.4 in the downloading list. I install cuda-nvcc=11.7 separately and this works.

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

3 participants