-
Notifications
You must be signed in to change notification settings - Fork 27.8k
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
A warning message showing that MultiScaleDeformableAttention.so
is not found in /root/.cache/torch_extensions
if ninja
is installed with transformers
#35349
Comments
This seems like an interaction between |
Thank you for letting me know that! I am not familiar with CUDA. It may take me a few days to check how to reproduce this issue with that library. I will try to do that and submit another issue to that repository. |
Hello, I've encountered a similar issue. May I ask if there has been any progress? This is the warning I received when loading DINO: [WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,888 >> Could not load the custom kernel for multi-scale deformable attention: Error building extension 'MultiScaleDeformableAttention': [1/4] /usr/bin/nvcc --generate-dependencies-with-compile --dependency-output ms_deform_attn_cuda.cuda.o.d -DTORCH_EXTENSION_NAME=MultiScaleDeformableAttention -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -I~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/TH -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/THC -isystem ~/anaconda3/envs/psp/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_80,code=sm_80 --compiler-options '-fPIC' -DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -std=c++17 -c ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/cuda/ms_deform_attn_cuda.cu -o ms_deform_attn_cuda.cuda.o
FAILED: ms_deform_attn_cuda.cuda.o
/usr/bin/nvcc --generate-dependencies-with-compile --dependency-output ms_deform_attn_cuda.cuda.o.d -DTORCH_EXTENSION_NAME=MultiScaleDeformableAttention -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -I~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/TH -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/THC -isystem ~/anaconda3/envs/psp/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_BFLOAT16_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr -gencode=arch=compute_80,code=sm_80 --compiler-options '-fPIC' -DCUDA_HAS_FP16=1 -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ -std=c++17 -c ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/cuda/ms_deform_attn_cuda.cu -o ms_deform_attn_cuda.cuda.o
<command-line>: fatal error: cuda_runtime.h: No such file or directory
compilation terminated.
[2/4] c++ -MMD -MF ms_deform_attn_cpu.o.d -DTORCH_EXTENSION_NAME=MultiScaleDeformableAttention -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -I~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/TH -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/THC -isystem ~/anaconda3/envs/psp/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++17 -DWITH_CUDA=1 -c ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/cpu/ms_deform_attn_cpu.cpp -o ms_deform_attn_cpu.o
[3/4] c++ -MMD -MF vision.o.d -DTORCH_EXTENSION_NAME=MultiScaleDeformableAttention -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -I~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/api/include -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/TH -isystem ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/THC -isystem ~/anaconda3/envs/psp/include/python3.10 -D_GLIBCXX_USE_CXX11_ABI=0 -fPIC -std=c++17 -DWITH_CUDA=1 -c ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/vision.cpp -o vision.o
In file included from ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/vision.cpp:11:
~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/ms_deform_attn.h: In function ‘at::Tensor ms_deform_attn_forward(const at::Tensor&, const at::Tensor&, const at::Tensor&, const at::Tensor&, const at::Tensor&, int)’:
~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/ms_deform_attn.h:29:19: warning: ‘at::DeprecatedTypeProperties& at::Tensor::type() const’ is deprecated: Tensor.type() is deprecated. Instead use Tensor.options(), which in many cases (e.g. in a constructor) is a drop-in replacement. If you were using data from type(), that is now available from Tensor itself, so instead of tensor.type().scalar_type(), use tensor.scalar_type() instead and instead of tensor.type().backend() use tensor.device(). [-Wdeprecated-declarations]
29 | if (value.type().is_cuda())
| ~~~~~~~~~~^~
In file included from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/ATen/core/Tensor.h:3,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/ATen/Tensor.h:3,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/function_hook.h:3,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/cpp_hook.h:2,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/variable.h:6,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/autograd.h:3,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/extension.h:5,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/cpu/ms_deform_attn_cpu.h:12,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/ms_deform_attn.h:13,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/vision.cpp:11:
~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/ATen/core/TensorBody.h:225:30: note: declared here
225 | DeprecatedTypeProperties & type() const {
| ^~~~
In file included from ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/vision.cpp:11:
~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/ms_deform_attn.h: In function ‘std::vector<at::Tensor> ms_deform_attn_backward(const at::Tensor&, const at::Tensor&, const at::Tensor&, const at::Tensor&, const at::Tensor&, const at::Tensor&, int)’:
~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/ms_deform_attn.h:51:19: warning: ‘at::DeprecatedTypeProperties& at::Tensor::type() const’ is deprecated: Tensor.type() is deprecated. Instead use Tensor.options(), which in many cases (e.g. in a constructor) is a drop-in replacement. If you were using data from type(), that is now available from Tensor itself, so instead of tensor.type().scalar_type(), use tensor.scalar_type() instead and instead of tensor.type().backend() use tensor.device(). [-Wdeprecated-declarations]
51 | if (value.type().is_cuda())
| ~~~~~~~~~~^~
In file included from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/ATen/core/Tensor.h:3,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/ATen/Tensor.h:3,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/function_hook.h:3,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/cpp_hook.h:2,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/variable.h:6,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/autograd/autograd.h:3,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/autograd.h:3,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/torch/extension.h:5,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/cpu/ms_deform_attn_cpu.h:12,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/ms_deform_attn.h:13,
from ~/anaconda3/envs/psp/lib/python3.10/site-packages/transformers/kernels/deformable_detr/vision.cpp:11:
~/anaconda3/envs/psp/lib/python3.10/site-packages/torch/include/ATen/core/TensorBody.h:225:30: note: declared here
225 | DeprecatedTypeProperties & type() const {
| ^~~~
ninja: build stopped: subcommand failed.
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,893 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,896 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,900 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,903 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,906 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,909 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,912 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,915 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,918 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,921 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory
[WARNING|modeling_grounding_dino.py:628] 2025-01-11 00:50:18,923 >> Could not load the custom kernel for multi-scale deformable attention: ~/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/MultiScaleDeformableAttention.so: cannot open shared object file: No such file or directory The system env info of mine:
|
I'm encountering a similar issue. Any updates appreciated! |
Can someone open an issue with DeformableDETR? I'm not sure what we can do at our end! |
@Rocketknight1 I am preparing some testing scripts now. After finishing them, I will report an update here and submit the issue to DeformableDETR. |
My conclusionCurrently, the multi-scale deformable attention seems to require the CUDA dev files. It needs the
A workaroundI have tried to use a different docker image docker run --gpus all -it --rm --shm-size=1g nvcr.io/nvidia/pytorch:24.12-py3 and repeat the same steps mentioned above. This time, these error messages do not appear even if Tip
I believe that a key reason is because this image contains the CUDA dev files and the A further try by copying the missing library fileAfter successfully using
Another test by copying the missing library fileWell, it is difficult to make Debian's GLibC version (2.38) the same as Ubuntu (3.4). I think I should use a Debian image to build the package. So, this time, I tried the following things:
@pspdada I think the issue you encountered is mainly due to the lack of the CUDA dev files. This line tells you why your build fails: fatal error: cuda_runtime.h: No such file or directory However, the warning like these should not cause the failure of building the package. if (value.type().is_cuda())
~~~~~~~~~~^~ I did not use I highly recommend you use docker and a docker image |
I have submitted the issue in fundamentalvision/Deformable-DETR#244 Hopefully, my tests can provide usable information. |
Having the same problem here! Any updates? |
I also faced an issue using DefarmableAttention, trying to figure out how this could be fixed.. In my environment, I'm getting Meanwhile, you can disable custom kernels to avoid an error/warning: # Grounding DINO
model = AutoModelForZeroShotObjectDetection.from_pretrained(checkpoint, disable_custom_kernels=True) |
I met the same problem.
gets stuck. |
Hey, if you're using latest torch, it breaks compilation for custom kernels, there's is a PR to fix it |
System Info
transformers
:4.47.1
torch
:2.5.1
timm
:1.0.12
ninja
:1.11.1.3
python
:3.10.14
pip
:23.0.1
torch
:nvidia-cuda-runtime-cu12==12.4.127
10.0.22631 Build 22631
)27.3.1, build ce12230
565.57.02
Who can help?
I am asking help for
DeformableDetrModel
vision models: @amyeroberts, @qubvel
Information
Tasks
examples
folder (such as GLUE/SQuAD, ...)Reproduction
/root/.cache/torch_extensions/py310_cu124/MultiScaleDeformableAttention/
is empty.The issue happens only when both
ninja
andtransformers
are installed. I believe that the following issue may be related to this issue:https://app.semanticdiff.com/gh/huggingface/transformers/pull/32834/overview
Expected behavior
It seems that ninja will let
DeformableDetrModel
throw unexpected error messages (despite that the script still works). That's may be because I am using a container without any compiler or CUDA preinstalled (the CUDA run time is installed bypip
).I think there should be a check that automatically turn of the
ninja
related functionalities even ifninja
is installed bypip
, as long as the requirements like compiler version, CUDA path, or something, are not fulfilled.The text was updated successfully, but these errors were encountered: