fundamentalvision / Deformable-DETR

Deformable DETR: Deformable Transformers for End-to-End Object Detection.
Apache License 2.0
3.2k stars 520 forks source link

RuntimeError: Error compiling objects for extension #25

Closed zoujinger closed 3 years ago

zoujinger commented 3 years ago

Hi, could someone help me?

when I Compiling CUDA operators, this error happens:

(deformable_detr) zyi@ZHU:~/Documents/Project/Deformable-DETR/models/ops$ sh ./make.sh running build running build_py running build_ext building 'MultiScaleDeformableAttention' extension Emitting ninja build file /home/zyi/Documents/Project/Deformable-DETR/models/ops/build/temp.linux-x86_64-3.7/build.ninja... Compiling objects... Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N) [1/2] /usr/local/cuda-10.2/bin/nvcc -DWITH_CUDA -I/home/zyi/Documents/Project/Deformable-DETR/models/ops/src -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/TH -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/home/zyi/anaconda3/envs/deformable_detr/include/python3.7m -c -c /home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cuda/ms_deform_attn_cuda.cu -o /home/zyi/Documents/Project/Deformable-DETR/models/ops/build/temp.linux-x86_64-3.7/home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cuda/ms_deform_attn_cuda.o -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -DCUDA_HAS_FP16=1 -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=MultiScaleDeformableAttention -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_61,code=sm_61 -std=c++14 FAILED: /home/zyi/Documents/Project/Deformable-DETR/models/ops/build/temp.linux-x86_64-3.7/home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cuda/ms_deform_attn_cuda.o /usr/local/cuda-10.2/bin/nvcc -DWITH_CUDA -I/home/zyi/Documents/Project/Deformable-DETR/models/ops/src -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/TH -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/home/zyi/anaconda3/envs/deformable_detr/include/python3.7m -c -c /home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cuda/ms_deform_attn_cuda.cu -o /home/zyi/Documents/Project/Deformable-DETR/models/ops/build/temp.linux-x86_64-3.7/home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cuda/ms_deform_attn_cuda.o -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS --expt-relaxed-constexpr --compiler-options ''"'"'-fPIC'"'"'' -DCUDA_HAS_FP16=1 -DCUDA_NO_HALF_OPERATORS -DCUDA_NO_HALF_CONVERSIONS -DCUDA_NO_HALF2_OPERATORS -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=MultiScaleDeformableAttention -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_61,code=sm_61 -std=c++14 /bin/sh: 1: /usr/local/cuda-10.2/bin/nvcc: not found [2/2] c++ -MMD -MF /home/zyi/Documents/Project/Deformable-DETR/models/ops/build/temp.linux-x86_64-3.7/home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cpu/ms_deform_attn_cpu.o.d -pthread -B /home/zyi/anaconda3/envs/deformable_detr/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/zyi/Documents/Project/Deformable-DETR/models/ops/src -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/TH -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/home/zyi/anaconda3/envs/deformable_detr/include/python3.7m -c -c /home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cpu/ms_deform_attn_cpu.cpp -o /home/zyi/Documents/Project/Deformable-DETR/models/ops/build/temp.linux-x86_64-3.7/home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cpu/ms_deform_attn_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=MultiScaleDeformableAttention -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14 FAILED: /home/zyi/Documents/Project/Deformable-DETR/models/ops/build/temp.linux-x86_64-3.7/home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cpu/ms_deform_attn_cpu.o c++ -MMD -MF /home/zyi/Documents/Project/Deformable-DETR/models/ops/build/temp.linux-x86_64-3.7/home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cpu/ms_deform_attn_cpu.o.d -pthread -B /home/zyi/anaconda3/envs/deformable_detr/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/zyi/Documents/Project/Deformable-DETR/models/ops/src -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/TH -I/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/home/zyi/anaconda3/envs/deformable_detr/include/python3.7m -c -c /home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cpu/ms_deform_attn_cpu.cpp -o /home/zyi/Documents/Project/Deformable-DETR/models/ops/build/temp.linux-x86_64-3.7/home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cpu/ms_deform_attn_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=MultiScaleDeformableAttention -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14 cc1plus: warning: command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++ In file included from /home/zyi/Documents/Project/Deformable-DETR/models/ops/src/cpu/ms_deform_attn_cpu.cpp:14:0: /home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/include/ATen/cuda/CUDAContext.h:5:30: fatal error: cuda_runtime_api.h: No such file or directory compilation terminated. ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1423, in _run_ninja_build check=True) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/subprocess.py", line 512, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "setup.py", line 70, in cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension}, File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/setuptools/init.py", line 153, in setup return distutils.core.setup(**attrs) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/distutils/core.py", line 148, in setup dist.run_commands() File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 79, in run _build_ext.run(self) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run _build_ext.build_ext.run(self) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/distutils/command/build_ext.py", line 340, in run self.build_extensions() File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 603, in build_extensions build_ext.build_extensions(self) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions _build_ext.build_ext.build_extensions(self) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/distutils/command/build_ext.py", line 449, in build_extensions self._build_extensions_serial() File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/distutils/command/build_ext.py", line 474, in _build_extensions_serial self.build_extension(ext) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 196, in build_extension _build_ext.build_extension(self, ext) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/distutils/command/build_ext.py", line 534, in build_extension depends=ext.depends) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 437, in unix_wrap_ninja_compile with_cuda=with_cuda) File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1163, in _write_ninja_file_and_compile_objects error_prefix='Error compiling objects for extension') File "/home/zyi/anaconda3/envs/deformable_detr/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1436, in _run_ninja_build raise RuntimeError(message) RuntimeError: Error compiling objects for extension

My CUDA version is 10.1 install pytorch==1.5.1 torchvision==0.6.1

zoujinger commented 3 years ago

Sorry for bothering. this issue is caused by PATH. I've solved it.

kuiran commented 3 years ago

Sorry for bothering. this issue is caused by PATH. I've solved it.

How to solve this problem?

ts-kim commented 3 years ago

Sorry for bothering. this issue is caused by PATH. I've solved it.

How to solve this problem?

Try this solution https://github.com/fundamentalvision/Deformable-DETR/issues/10#issue-761094702