DCNv2 RuntimeError: Error compiling objects for extension

最近使用CenterNet的时候,由于在DLA34中用到了DCN,所以需要编译DCNv2,但是每次都会出问题,最近做一个小结
1、Pytorch版本:1.6
2、DCN选择:https://github.com/lbin/DCNv2,这个链接中针对pytorch不同版本做了相应改变,切换分支即可

git checkout -b  pytorch_1.6  origin/pytorch_1.6

但是编译的时候遇到了报错:

...
/bin/sh: 1: :/usr/local/cuda-10.0/bin/nvcc: not found
ninja: build stopped: subcommand failed.

'''
RuntimeError: Error compiling objects for extension

从最后的报错看不出来,需要到中间这个报错nvcc: not found 去找原因,参考了这位博主安装 maskrcnn-benchmark: command ‘:/usr/local/cuda/bin/nvcc’ failed with exit status 1 的解决方案,是环境变量中的问题,需要在 ~/.bashrc 中修改:

export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
# 改成下面的:(原来上面这个不太好)
export CUDA_HOME=/usr/local/cuda

然后再编译即可

sh make.sh
已标记关键词 清除标记
<div><p>hello, Auther, Thank you for wonderful work! Rencently, I used make.sh to build, but I get RuntimeError. Here is my environment: Ubuntu 16.04 + pytorch 1.5 + cuda 10.2 + python 3.7</p> <p>running build running build_ext building '_ext' extension Emitting ninja build file /home/yix/git/DCNv2/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/1] /usr/local/cuda-10.2/bin/nvcc -DWITH_CUDA -I/home/yix/git/DCNv2/src -I/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/include -I/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/include/TH -I/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/include/python3.7m -c -c /home/yix/git/DCNv2/src/cuda/dcn_v2_cuda.cu -o /home/yix/git/DCNv2/build/temp.linux-x86_64-3.7/home/yix/git/DCNv2/src/cuda/dcn_v2_cuda.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_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 -DTORCH_EXTENSION_NAME=_ext -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=sm_75 -std=c++14 FAILED: /home/yix/git/DCNv2/build/temp.linux-x86_64-3.7/home/yix/git/DCNv2/src/cuda/dcn_v2_cuda.o /usr/local/cuda-10.2/bin/nvcc -DWITH_CUDA -I/home/yix/git/DCNv2/src -I/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/include -I/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/include/TH -I/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda-10.2/include -I/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/include/python3.7m -c -c /home/yix/git/DCNv2/src/cuda/dcn_v2_cuda.cu -o /home/yix/git/DCNv2/build/temp.linux-x86_64-3.7/home/yix/git/DCNv2/src/cuda/dcn_v2_cuda.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_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 -DTORCH_EXTENSION_NAME=_ext -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=sm_75 -std=c++14 /home/yix/git/DCNv2/src/cuda/dcn_v2_cuda.cu(107): error: identifier "THCState_getCurrentStream" is undefined</p> <p>/home/yix/git/DCNv2/src/cuda/dcn_v2_cuda.cu(279): error: identifier "THCState_getCurrentStream" is undefined</p> <p>2 errors detected in the compilation of "/tmp/tmpxft_00002554_00000000-6_dcn_v2_cuda.cpp1.ii". ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1400, in _run_ninja_build check=True) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/subprocess.py", line 468, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.</p> <p>During handling of the above exception, another exception occurred:</p> <p>Traceback (most recent call last): File "setup.py", line 70, in cmdclass={"build_ext": torch.utils.cpp_extension.BuildExtension}, File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/setuptools/<strong>init</strong>.py", line 144, in setup return distutils.core.setup(**attrs) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/distutils/core.py", line 148, in setup dist.run_commands() File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/distutils/cmd.py", line 313, in run_command self.distribution.run_command(command) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 87, in run _build_ext.run(self) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run _build_ext.build_ext.run(self) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/distutils/command/build_ext.py", line 339, in run self.build_extensions() File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 580, in build_extensions build_ext.build_extensions(self) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/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/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/distutils/command/build_ext.py", line 448, in build_extensions self._build_extensions_serial() File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/distutils/command/build_ext.py", line 473, in _build_extensions_serial self.build_extension(ext) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 208, in build_extension _build_ext.build_extension(self, ext) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/distutils/command/build_ext.py", line 533, in build_extension depends=ext.depends) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 423, in unix_wrap_ninja_compile with_cuda=with_cuda) File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1140, in _write_ninja_file_and_compile_objects error_prefix='Error compiling objects for extension') File "/home/yix/anaconda3/envs/py3.7+torch1.5+10.2/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1413, in _run_ninja_build raise RuntimeError(message) RuntimeError: Error compiling objects for extension</p> <p>How to solve this problem ?</p><p>该提问来源于开源项目:CharlesShang/DCNv2</p></div>
<div><p>Hi, I followed the steps provided in README. I create a virtual environment and installed latest version PyTorch. When I execute <code>python setup.py build_ext --inplace</code> or <code>python setup.py install</code>, I encountered the following errors. I have tried both python 3.6 and python 3.7. The results are the same. My cuda version is 10.2, PyTorch is 1.5, NumPy is 1.18, ninja version is 1.10. The OS is Ubuntu 18.04. Thanks for your help!</p> <p>[2/2] /usr/local/cuda/bin/nvcc -I/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/torch/include -I/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/torch/include/TH -I/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/torch/include/THC -I/usr/local/cuda/include -I/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/numpy/core/include -I/home/yyyeh/anaconda3/envs/kaolin/include/python3.7m -c -c /home/yyyeh/library/kaolin/kaolin/cuda/load_textures_cuda_kernel.cu -o /home/yyyeh/library/kaolin/build/temp.linux-x86_64-3.7/kaolin/cuda/load_textures_cuda_kernel.o -D__CUDA_NO_HALF_OPERATORS__ -D__CUDA_NO_HALF_CONVERSIONS__ -D__CUDA_NO_HALF2_OPERATORS__ --expt-relaxed-constexpr --compiler-options '-fPIC' -Wno-deprecated-declarations -DTORCH_API_INCLUDE_EXTENSION_H -DTORCH_EXTENSION_NAME=load_textures -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_75,code=sm_75 -std=c++14 ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1400, in _run_ninja_build check=True) File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/subprocess.py", line 512, in run output=stdout, stderr=stderr) subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.</p> <p>During handling of the above exception, another exception occurred:</p> <p>Traceback (most recent call last): File "setup.py", line 230, in cmdclass={'build_ext': KaolinBuildExtension} File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/setuptools/<strong>init</strong>.py", line 144, in setup return distutils.core.setup(**attrs) File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/distutils/core.py", line 148, in setup dist.run_commands() File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/distutils/dist.py", line 966, in run_commands self.run_command(cmd) File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/distutils/dist.py", line 985, in run_command cmd_obj.run() File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 87, in run _build_ext.run(self) File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/distutils/command/build_ext.py", line 340, in run self.build_extensions() File "setup.py", line 89, in build_extensions super().build_extensions() File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 580, in build_extensions build_ext.build_extensions(self) File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/distutils/command/build_ext.py", line 449, in build_extensions self._build_extensions_serial() File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/distutils/command/build_ext.py", line 474, in _build_extensions_serial self.build_extension(ext) File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 208, in build_extension _build_ext.build_extension(self, ext) File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/distutils/command/build_ext.py", line 534, in build_extension depends=ext.depends) File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 423, in unix_wrap_ninja_compile with_cuda=with_cuda) File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1140, in _write_ninja_file_and_compile_objects error_prefix='Error compiling objects for extension') File "/home/yyyeh/anaconda3/envs/kaolin/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1413, in _run_ninja_build raise RuntimeError(message) RuntimeError: Error compiling objects for extension</p><p>该提问来源于开源项目:NVIDIAGameWorks/kaolin</p></div>
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页