Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

RuntimeError: Error compiling objects for extension #67

Open
xiaosa269 opened this issue Jan 24, 2024 · 3 comments
Open

RuntimeError: Error compiling objects for extension #67

xiaosa269 opened this issue Jan 24, 2024 · 3 comments

Comments

@xiaosa269
Copy link

Hello, I encountered the following error while performing the step "cd third_party/SparseTransformer && python setup.py install" on GitHub. Could you please advise me on how to resolve it? Thank you very much for your assistance.
running install
/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/command/install.py:37: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
setuptools.SetuptoolsDeprecationWarning,
/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/command/easy_install.py:147: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
EasyInstallDeprecationWarning,
running bdist_egg
running egg_info
writing sptr.egg-info/PKG-INFO
writing dependency_links to sptr.egg-info/dependency_links.txt
writing top-level names to sptr.egg-info/top_level.txt
reading manifest file 'sptr.egg-info/SOURCES.txt'
writing manifest file 'sptr.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
building 'sptr_cuda' extension
Emitting ninja build file /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/build.ninja...
Compiling objects...
Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
[1/3] /usr/bin/nvcc --generate-dependencies-with-compile --dependency-output /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/attention/attention_cuda_kernel.o.d -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/TH -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/THC -I/home/xhy/miniconda3/envs/SphereFormer/include/python3.7m -c -c /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/src/sptr/attention/attention_cuda_kernel.cu -o /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/attention/attention_cuda_kernel.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'"'"'' -O2 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="gcc"' '-DPYBIND11_STDLIB="libstdcpp"' '-DPYBIND11_BUILD_ABI="cxxabi1011"' -DTORCH_EXTENSION_NAME=sptr_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 -std=c++14
FAILED: /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/attention/attention_cuda_kernel.o
/usr/bin/nvcc --generate-dependencies-with-compile --dependency-output /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/attention/attention_cuda_kernel.o.d -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/TH -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/THC -I/home/xhy/miniconda3/envs/SphereFormer/include/python3.7m -c -c /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/src/sptr/attention/attention_cuda_kernel.cu -o /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/attention/attention_cuda_kernel.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'"'"'' -O2 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="gcc"' '-DPYBIND11_STDLIB="libstdcpp"' '-DPYBIND11_BUILD_ABI="cxxabi1011"' -DTORCH_EXTENSION_NAME=sptr_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 -std=c++14
nvcc fatal : Unknown option '-generate-dependencies-with-compile'
[2/3] /usr/bin/nvcc --generate-dependencies-with-compile --dependency-output /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/rpe/relative_pos_encoding_cuda_kernel.o.d -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/TH -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/THC -I/home/xhy/miniconda3/envs/SphereFormer/include/python3.7m -c -c /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/src/sptr/rpe/relative_pos_encoding_cuda_kernel.cu -o /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/rpe/relative_pos_encoding_cuda_kernel.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'"'"'' -O2 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="gcc"' '-DPYBIND11_STDLIB="libstdcpp"' '-DPYBIND11_BUILD_ABI="cxxabi1011"' -DTORCH_EXTENSION_NAME=sptr_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 -std=c++14
FAILED: /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/rpe/relative_pos_encoding_cuda_kernel.o
/usr/bin/nvcc --generate-dependencies-with-compile --dependency-output /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/rpe/relative_pos_encoding_cuda_kernel.o.d -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/TH -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/THC -I/home/xhy/miniconda3/envs/SphereFormer/include/python3.7m -c -c /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/src/sptr/rpe/relative_pos_encoding_cuda_kernel.cu -o /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/rpe/relative_pos_encoding_cuda_kernel.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'"'"'' -O2 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="gcc"' '-DPYBIND11_STDLIB="libstdcpp"' '-DPYBIND11_BUILD_ABI="cxxabi1011"' -DTORCH_EXTENSION_NAME=sptr_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 -std=c++14
nvcc fatal : Unknown option '-generate-dependencies-with-compile'
[3/3] /usr/bin/nvcc --generate-dependencies-with-compile --dependency-output /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/precompute/precompute_cuda_kernel.o.d -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/TH -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/THC -I/home/xhy/miniconda3/envs/SphereFormer/include/python3.7m -c -c /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/src/sptr/precompute/precompute_cuda_kernel.cu -o /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/precompute/precompute_cuda_kernel.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'"'"'' -O2 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="gcc"' '-DPYBIND11_STDLIB="libstdcpp"' '-DPYBIND11_BUILD_ABI="cxxabi1011"' -DTORCH_EXTENSION_NAME=sptr_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 -std=c++14
FAILED: /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/precompute/precompute_cuda_kernel.o
/usr/bin/nvcc --generate-dependencies-with-compile --dependency-output /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/precompute/precompute_cuda_kernel.o.d -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/torch/csrc/api/include -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/TH -I/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/include/THC -I/home/xhy/miniconda3/envs/SphereFormer/include/python3.7m -c -c /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/src/sptr/precompute/precompute_cuda_kernel.cu -o /home/xhy/code/SphereFormer-master/third_party/SparseTransformer/build/temp.linux-x86_64-cpython-37/src/sptr/precompute/precompute_cuda_kernel.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'"'"'' -O2 -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=sptr_cuda -D_GLIBCXX_USE_CXX11_ABI=0 -gencode=arch=compute_86,code=compute_86 -gencode=arch=compute_86,code=sm_86 -std=c++14
nvcc fatal : Unknown option '-generate-dependencies-with-compile'
ninja: build stopped: subcommand failed.
Traceback (most recent call last):
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1673, in _run_ninja_build
env=env)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/subprocess.py", line 512, in run
output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command '['ninja', '-v']' returned non-zero exit status 1.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "setup.py", line 27, in
cmdclass={'build_ext': BuildExtension}
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/init.py", line 87, in setup
return distutils.core.setup(**attrs)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 185, in setup
return run_commands(dist)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
dist.run_commands()
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
self.run_command(cmd)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/dist.py", line 1208, in run_command
super().run_command(command)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/command/install.py", line 74, in run
self.do_egg_install()
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/command/install.py", line 123, in do_egg_install
self.run_command('bdist_egg')
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
self.distribution.run_command(command)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/dist.py", line 1208, in run_command
super().run_command(command)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 165, in run
cmd = self.call_command('install_lib', warn_dir=0)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/command/bdist_egg.py", line 151, in call_command
self.run_command(cmdname)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
self.distribution.run_command(command)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/dist.py", line 1208, in run_command
super().run_command(command)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/command/install_lib.py", line 11, in run
self.build()
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/command/install_lib.py", line 112, in build
self.run_command('build_ext')
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
self.distribution.run_command(command)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/dist.py", line 1208, in run_command
super().run_command(command)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
cmd_obj.run()
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 84, in run
_build_ext.run(self)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
self.build_extensions()
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 708, in build_extensions
build_ext.build_extensions(self)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 468, in build_extensions
self._build_extensions_serial()
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 494, in _build_extensions_serial
self.build_extension(ext)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
_build_ext.build_extension(self, ext)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/setuptools/_distutils/command/build_ext.py", line 556, in build_extension
depends=ext.depends,
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 538, in unix_wrap_ninja_compile
with_cuda=with_cuda)
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1359, in _write_ninja_file_and_compile_objects
error_prefix='Error compiling objects for extension')
File "/home/xhy/miniconda3/envs/SphereFormer/lib/python3.7/site-packages/torch/utils/cpp_extension.py", line 1683, in _run_ninja_build
raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension

@Vonct
Copy link

Vonct commented Mar 6, 2024

same issue. Have you solved it?

@Tombo551
Copy link

Tombo551 commented May 2, 2024

Had the same issue, solved it by changing all the occurences of #include <THC/THC.h> to #include <ATen/ATen.h>. The reason is that the namespace THC is deprecated and functions were moved to ATen namespace, as discussed in https://discuss.pytorch.org/t/question-about-thc-thc-h/147145/11

@Wansit99
Copy link

Wansit99 commented Nov 6, 2024

Had the same issue, solved it by changing all the occurences of #include <THC/THC.h> to #include <ATen/ATen.h>. The reason is that the namespace THC is deprecated and functions were moved to ATen namespace, as discussed in https://discuss.pytorch.org/t/question-about-thc-thc-h/147145/11

Thanks! It work for me!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants