Grounded-Segment-Anything icon indicating copy to clipboard operation
Grounded-Segment-Anything copied to clipboard

解决error: subprocess-exited-with-error

Open lu-ran-qi-ran opened this issue 7 months ago • 3 comments

我的报错是这样的: Building wheels for collected packages: groundingdino Building editable for groundingdino (pyproject.toml) ... error error: subprocess-exited-with-error

× Building editable for groundingdino (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [41 lines of output] /tmp/pip-build-env-f07q34bg/overlay/lib/python3.10/site-packages/torch/subclasses/functional_tensor.py:276: UserWarning: Failed to initialize NumPy: No module named 'numpy' (Triggered internally at /pytorch/torch/csrc/utils/tensor_numpy.cpp:81.) cpu = conversion_method_template(device=torch.device("cpu")) Building wheel groundingdino-0.1.0 Compiling with CUDA running editable_wheel creating /tmp/pip-wheel-2lh58iqk/.tmp-966g83g9/groundingdino.egg-info writing /tmp/pip-wheel-2lh58iqk/.tmp-966g83g9/groundingdino.egg-info/PKG-INFO writing dependency_links to /tmp/pip-wheel-2lh58iqk/.tmp-966g83g9/groundingdino.egg-info/dependency_links.txt writing requirements to /tmp/pip-wheel-2lh58iqk/.tmp-966g83g9/groundingdino.egg-info/requires.txt writing top-level names to /tmp/pip-wheel-2lh58iqk/.tmp-966g83g9/groundingdino.egg-info/top_level.txt writing manifest file '/tmp/pip-wheel-2lh58iqk/.tmp-966g83g9/groundingdino.egg-info/SOURCES.txt' /tmp/pip-build-env-f07q34bg/overlay/lib/python3.10/site-packages/torch/utils/cpp_extension.py:576: 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.')) reading manifest file '/tmp/pip-wheel-2lh58iqk/.tmp-966g83g9/groundingdino.egg-info/SOURCES.txt' adding license file 'LICENSE' writing manifest file '/tmp/pip-wheel-2lh58iqk/.tmp-966g83g9/groundingdino.egg-info/SOURCES.txt' creating '/tmp/pip-wheel-2lh58iqk/.tmp-966g83g9/groundingdino-0.1.0.dist-info' creating /tmp/pip-wheel-2lh58iqk/.tmp-966g83g9/groundingdino-0.1.0.dist-info/WHEEL running build_py running build_ext /tmp/pip-build-env-f07q34bg/overlay/lib/python3.10/site-packages/torch/utils/cpp_extension.py:480: UserWarning: The detected CUDA version (12.1) has a minor version mismatch with the version that was used to compile PyTorch (12.6). Most likely this shouldn't be a problem. warnings.warn(CUDA_MISMATCH_WARN.format(cuda_str_version, torch.version.cuda)) /tmp/pip-build-env-f07q34bg/overlay/lib/python3.10/site-packages/torch/utils/cpp_extension.py:490: UserWarning: There are no x86_64-linux-gnu-g++ version bounds defined for CUDA version 12.1 warnings.warn(f'There are no {compiler_name} version bounds defined for CUDA version {cuda_str_version}') building 'groundingdino.C' extension creating /tmp/tmpgkqpqk0s.build-temp/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn x86_64-linux-gnu-g++ -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -g -fwrapv -O2 -fPIC -DWITH_CUDA -I/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc -I/tmp/pip-build-env-f07q34bg/overlay/lib/python3.10/site-packages/torch/include -I/tmp/pip-build-env-f07q34bg/overlay/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/usr/local/cuda-12.1/include -I/home/ss/code/Grounded-Segment-Anything/.venv/include -I/usr/include/python3.10 -c /home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cpu.cpp -o /tmp/tmpgkqpqk0s.build-temp/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="gcc" -DPYBIND11_STDLIB="libstdcpp" -DPYBIND11_BUILD_ABI="cxxabi1016" -DTORCH_EXTENSION_NAME=C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++17 /tmp/pip-build-env-f07q34bg/overlay/lib/python3.10/site-packages/torch/utils/cpp_extension.py:2356: UserWarning: TORCH_CUDA_ARCH_LIST is not set, all archs for visible cards are included for compilation. If this is not desired, please set os.environ['TORCH_CUDA_ARCH_LIST']. warnings.warn( /usr/local/cuda-12.1/bin/nvcc -DWITH_CUDA -I/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc -I/tmp/pip-build-env-f07q34bg/overlay/lib/python3.10/site-packages/torch/include -I/tmp/pip-build-env-f07q34bg/overlay/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -I/usr/local/cuda-12.1/include -I/home/ss/code/Grounded-Segment-Anything/.venv/include -I/usr/include/python3.10 -c /home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu -o /tmp/tmpgkqpqk0s.build-temp/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.o -D__CUDA_NO_HALF_OPERATORS -D__CUDA_NO_HALF_CONVERSIONS -D__CUDA_NO_BFLOAT16_CONVERSIONS -D__CUDA_NO_HALF2_OPERATORS_ --expt-relaxed-constexpr --compiler-options '-fPIC' -DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE="gcc" -DPYBIND11_STDLIB="libstdcpp" -DPYBIND11_BUILD_ABI="cxxabi1016" -DTORCH_EXTENSION_NAME=C -D_GLIBCXX_USE_CXX11_ABI=1 -gencode=arch=compute_89,code=compute_89 -gencode=arch=compute_89,code=sm_89 -std=c++17 /home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu(65): error: no suitable conversion function from "const at::DeprecatedTypeProperties" to "c10::ScalarType" exists [&] { const auto& the_type = value.type(); constexpr const char* at_dispatch_name = "ms_deform_attn_forward_cuda"; at::ScalarType st = ::detail::scalar_type(the_type); ; switch (st) { case at::ScalarType::Double: { do { if constexpr (!at::should_include_kernel_dtype( at_dispatch_name, at::ScalarType::Double)) { if (!(false)) { ::c10::detail::torchCheckFail( func, "/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu", static_cast<uint32_t>(65), (::c10::detail::torchCheckMsgImpl( "Expected " "false" " to be true, but got false. " "(Could this error message be improved? If so, " "please report an enhancement request to PyTorch.)", "dtype '", toString(at::ScalarType::Double), "' not selected for kernel tag ", at_dispatch_name))); }; } } while (0); using scalar_t [[maybe_unused]] = c10::impl::ScalarTypeToCPPTypeTat::ScalarType::Double; return ([&] { ms_deformable_im2col_cuda(at::cuda::getCurrentCUDAStream(), value.data<scalar_t>() + n * im2col_step * per_value_size, spatial_shapes.data<int64_t>(), level_start_index.data<int64_t>(), sampling_loc.data<scalar_t>() + n * im2col_step * per_sample_loc_size, attn_weight.data<scalar_t>() + n * im2col_step * per_attn_weight_size, batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, columns.data<scalar_t>()); })(); } case at::ScalarType::Float: { do { if constexpr (!at::should_include_kernel_dtype( at_dispatch_name, at::ScalarType::Float)) { if (!(false)) { ::c10::detail::torchCheckFail( func, "/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu", static_cast<uint32_t>(65), (::c10::detail::torchCheckMsgImpl( "Expected " "false" " to be true, but got false. " "(Could this error message be improved? If so, " "please report an enhancement request to PyTorch.)", "dtype '", toString(at::ScalarType::Float), "' not selected for kernel tag ", at_dispatch_name))); }; } } while (0); using scalar_t [[maybe_unused]] = c10::impl::ScalarTypeToCPPTypeTat::ScalarType::Float; return ([&] { ms_deformable_im2col_cuda(at::cuda::getCurrentCUDAStream(), value.data<scalar_t>() + n * im2col_step * per_value_size, spatial_shapes.data<int64_t>(), level_start_index.data<int64_t>(), sampling_loc.data<scalar_t>() + n * im2col_step * per_sample_loc_size, attn_weight.data<scalar_t>() + n * im2col_step * per_attn_weight_size, batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, columns.data<scalar_t>()); })(); } default: if (!(false)) { ::c10::detail::torchCheckFail( func, "/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu", static_cast<uint32_t>(65), (::c10::detail::torchCheckMsgImpl( "Expected " "false" " to be true, but got false. " "(Could this error message be improved? If so, " "please report an enhancement request to PyTorch.)", '"', at_dispatch_name, "" not implemented for '", toString(_st), "'"))); }; } }() ^

  /home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu(135): error: no suitable conversion function from "const at::DeprecatedTypeProperties" to "c10::ScalarType" exists
            [&] { const auto& the_type = value.type(); constexpr const char* at_dispatch_name = "ms_deform_attn_backward_cuda"; at::ScalarType _st = ::detail::scalar_type(the_type); ; switch (_st) { case at::ScalarType::Double: { do { if constexpr (!at::should_include_kernel_dtype( at_dispatch_name, at::ScalarType::Double)) { if (!(false)) { ::c10::detail::torchCheckFail( __func__, "/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu", static_cast<uint32_t>(135), (::c10::detail::torchCheckMsgImpl( "Expected " "false" " to be true, but got false.  " "(Could this error message be improved?  If so, " "please report an enhancement request to PyTorch.)", "dtype '", toString(at::ScalarType::Double), "' not selected for kernel tag ", at_dispatch_name))); }; } } while (0); using scalar_t [[maybe_unused]] = c10::impl::ScalarTypeToCPPTypeT<at::ScalarType::Double>; return ([&] { ms_deformable_col2im_cuda(at::cuda::getCurrentCUDAStream(), grad_output_g.data<scalar_t>(), value.data<scalar_t>() + n * im2col_step_ * per_value_size, spatial_shapes.data<int64_t>(), level_start_index.data<int64_t>(), sampling_loc.data<scalar_t>() + n * im2col_step_ * per_sample_loc_size, attn_weight.data<scalar_t>() + n * im2col_step_ * per_attn_weight_size, batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, grad_value.data<scalar_t>() + n * im2col_step_ * per_value_size, grad_sampling_loc.data<scalar_t>() + n * im2col_step_ * per_sample_loc_size, grad_attn_weight.data<scalar_t>() + n * im2col_step_ * per_attn_weight_size); })(); } case at::ScalarType::Float: { do { if constexpr (!at::should_include_kernel_dtype( at_dispatch_name, at::ScalarType::Float)) { if (!(false)) { ::c10::detail::torchCheckFail( __func__, "/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu", static_cast<uint32_t>(135), (::c10::detail::torchCheckMsgImpl( "Expected " "false" " to be true, but got false.  " "(Could this error message be improved?  If so, " "please report an enhancement request to PyTorch.)", "dtype '", toString(at::ScalarType::Float), "' not selected for kernel tag ", at_dispatch_name))); }; } } while (0); using scalar_t [[maybe_unused]] = c10::impl::ScalarTypeToCPPTypeT<at::ScalarType::Float>; return ([&] { ms_deformable_col2im_cuda(at::cuda::getCurrentCUDAStream(), grad_output_g.data<scalar_t>(), value.data<scalar_t>() + n * im2col_step_ * per_value_size, spatial_shapes.data<int64_t>(), level_start_index.data<int64_t>(), sampling_loc.data<scalar_t>() + n * im2col_step_ * per_sample_loc_size, attn_weight.data<scalar_t>() + n * im2col_step_ * per_attn_weight_size, batch_n, spatial_size, num_heads, channels, num_levels, num_query, num_point, grad_value.data<scalar_t>() + n * im2col_step_ * per_value_size, grad_sampling_loc.data<scalar_t>() + n * im2col_step_ * per_sample_loc_size, grad_attn_weight.data<scalar_t>() + n * im2col_step_ * per_attn_weight_size); })(); } default: if (!(false)) { ::c10::detail::torchCheckFail( __func__, "/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu", static_cast<uint32_t>(135), (::c10::detail::torchCheckMsgImpl( "Expected " "false" " to be true, but got false.  " "(Could this error message be improved?  If so, " "please report an enhancement request to PyTorch.)", '"', at_dispatch_name, "\" not implemented for '", toString(_st), "'"))); }; } }()
                                                                                                                                                                           ^
  
  2 errors detected in the compilation of "/home/ss/code/Grounded-Segment-Anything/GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu".
  error: command '/usr/local/cuda-12.1/bin/nvcc' 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 editable for groundingdino Failed to build groundingdino ERROR: Failed to build installable wheels for some pyproject.toml based projects (groundingdino)

解决方法: 修改 ms_deform_attn_cuda.cu 源码 错误主要源于下面这行代码(在 GroundingDINO 的 models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu): 65和135处value.type()需要替换为适配新版 PyTorch 的写法value.scalar_type()

lu-ran-qi-ran avatar May 27 '25 09:05 lu-ran-qi-ran

Thanks!!!

vantasyman avatar Aug 10 '25 04:08 vantasyman

helpful! thanks a bunch

IIIcecola avatar Sep 03 '25 01:09 IIIcecola

圣人啊哥

HaolinYouth avatar Oct 20 '25 05:10 HaolinYouth

English translation:

In both GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu and GroundingDINO/groundingdino/models/GroundingDINO/csrc/MsDeformAttn/ms_deform_attn_cuda.cu change value.type() to value.scalar_type() on line 65 and 135

My cuda setup for reference:

(hardware_env)  jstm ~/Projects/panda_utils nvidia-smi 
Mon Nov 17 16:23:44 2025       
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 550.90.07              Driver Version: 550.90.07      CUDA Version: 12.4     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                 Persistence-M | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 4080 ...    Off |   00000000:B3:00.0  On |                  N/A |
|  0%   42C    P8             19W /  320W |     779MiB /  16376MiB |      9%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

I also had to run conda install -c nvidia cuda-toolkit=12.8 to fix a previous issue.

jstmn avatar Nov 18 '25 00:11 jstmn