PointTransformer编译pointops_cuda报错fatal error: THC/THC.h: No such file or directory

错误信息

  • Ubuntu 20.04
  • CUDA 11.6
  • PyTorch 1.13.0

尝试运行PointTransformer代码, 编译pointops_cuda的时候报错:

> py setup.py install
running install
/home/dl/.conda/envs/dl/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/dl/.conda/envs/dl/lib/python3.8/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
running egg_info
creating pointops.egg-info
writing pointops.egg-info/PKG-INFO
writing dependency_links to pointops.egg-info/dependency_links.txt
writing top-level names to pointops.egg-info/top_level.txt
writing manifest file 'pointops.egg-info/SOURCES.txt'
/home/dl/.conda/envs/dl/lib/python3.8/site-packages/torch/utils/cpp_extension.py:476: 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 'pointops.egg-info/SOURCES.txt'
writing manifest file 'pointops.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
building 'pointops_cuda' extension
creating build
creating build/temp.linux-x86_64-cpython-38
creating build/temp.linux-x86_64-cpython-38/src
creating build/temp.linux-x86_64-cpython-38/src/aggregation
creating build/temp.linux-x86_64-cpython-38/src/grouping
creating build/temp.linux-x86_64-cpython-38/src/interpolation
creating build/temp.linux-x86_64-cpython-38/src/knnquery
creating build/temp.linux-x86_64-cpython-38/src/sampling
creating build/temp.linux-x86_64-cpython-38/src/subtraction
gcc -pthread -B /home/dl/.conda/envs/dl/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/dl/.conda/envs/dl/lib/python3.8/site-packages/torch/include -I/home/dl/.conda/envs/dl/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/dl/.conda/envs/dl/lib/python3.8/site-packages/torch/include/TH -I/home/dl/.conda/envs/dl/lib/python3.8/site-packages/torch/include/THC -I/home/dl/.conda/envs/dl/include -I/home/dl/.conda/envs/dl/include/python3.8 -c src/aggregation/aggregation_cuda.cpp -o build/temp.linux-x86_64-cpython-38/src/aggregation/aggregation_cuda.o -g -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -DTORCH_EXTENSION_NAME=pointops_cuda -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++
src/aggregation/aggregation_cuda.cpp:2:10: fatal error: THC/THC.h: 没有那个文件或目录
    2 | #include 
      |          ^~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1
(dl) dl@kemove-desktop:~/point-transformer/lib/pointops$ py setup.py install
running install
/home/dl/.conda/envs/dl/lib/python3.8/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
/home/dl/.conda/envs/dl/lib/python3.8/site-packages/setuptools/command/easy_install.py:144: EasyInstallDeprecationWarning: easy_install command is deprecated. Use build and pip and other standards-based tools.
  warnings.warn(
running bdist_egg
running egg_info
writing pointops.egg-info/PKG-INFO
writing dependency_links to pointops.egg-info/dependency_links.txt
writing top-level names to pointops.egg-info/top_level.txt
/home/dl/.conda/envs/dl/lib/python3.8/site-packages/torch/utils/cpp_extension.py:476: 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 'pointops.egg-info/SOURCES.txt'
writing manifest file 'pointops.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-x86_64/egg
running install_lib
running build_ext
building 'pointops_cuda' extension
gcc -pthread -B /home/dl/.conda/envs/dl/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/home/dl/.conda/envs/dl/lib/python3.8/site-packages/torch/include -I/home/dl/.conda/envs/dl/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/dl/.conda/envs/dl/lib/python3.8/site-packages/torch/include/TH -I/home/dl/.conda/envs/dl/lib/python3.8/site-packages/torch/include/THC -I/home/dl/.conda/envs/dl/include -I/home/dl/.conda/envs/dl/include/python3.8 -c src/aggregation/aggregation_cuda.cpp -o build/temp.linux-x86_64-cpython-38/src/aggregation/aggregation_cuda.o -g -DTORCH_API_INCLUDE_EXTENSION_H -DPYBIND11_COMPILER_TYPE=\"_gcc\" -DPYBIND11_STDLIB=\"_libstdcpp\" -DPYBIND11_BUILD_ABI=\"_cxxabi1011\" -DTORCH_EXTENSION_NAME=pointops_cuda -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++
src/aggregation/aggregation_cuda.cpp:2:10: fatal error: THC/THC.h: 没有那个文件或目录
    2 | #include 
      |          ^~~~~~~~~~~
compilation terminated.
error: command '/usr/bin/gcc' failed with exit code 1

原因

原因是pytorch 1.9之后的某个版本删除了THC.h, 参考 fatal error: THC/THC.h: No such file or directory - CSDN。

解决方法

先排除2个正确答案:
老老实实运行储存库提供的env_setup.sh新装一个pytorch=1.9.0的环境。
降级pytorch1.9.0

我使用的是下述方法:
Ctrl+Shift+F全局搜索并删除每一行#include
PointTransformer编译pointops_cuda报错fatal error: THC/THC.h: No such file or directory_第1张图片
然后再编译就能通过了

你可能感兴趣的:(debug,pytorch,python,深度学习,pytorch)