我的 gcc 和 g++ 出错

我的 gcc 和 g++ 出错

我正在尝试运行由facebook公司制作的Detectron项目的安装文件,但是我收到了一些错误,这些错误表明我的gcc/g++可能有问题,这些错误似乎来自于包含标准库头,但是我对此很陌生,无法弄清楚它到底是什么以及如何修复它。错误如下:

Running setup.py develop for detectron2
    ERROR: Command errored out with exit status 1:
     command: /home/steadysjtu/anaconda3/envs/detectron2/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/steadysjtu/projects/detectron2/setup.py'"'"'; __file__='"'"'/home/steadysjtu/projects/detectron2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps
         cwd: /home/steadysjtu/projects/detectron2/
    Complete output (186 lines):
    running develop
    running egg_info
    writing detectron2.egg-info/PKG-INFO
    writing dependency_links to detectron2.egg-info/dependency_links.txt
    writing requirements to detectron2.egg-info/requires.txt
    writing top-level names to detectron2.egg-info/top_level.txt
    reading manifest file 'detectron2.egg-info/SOURCES.txt'
    writing manifest file 'detectron2.egg-info/SOURCES.txt'
    running build_ext
    building 'detectron2._C' extension
    Emitting ninja build file /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/build.ninja...
    Compiling objects...
    Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
    /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/utils/cpp_extension.py:266: UserWarning:

                                   !! WARNING !!

    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
    Your compiler (c++) is not compatible with the compiler Pytorch was
    built with for this platform, which is g++ on linux. Please
    use g++ to to compile your extension. Alternatively, you may
    compile PyTorch from source using c++, and then you can also use
    c++ to compile your extension.

    See https://github.com/pytorch/pytorch/blob/master/CONTRIBUTING.md for help
    with compiling PyTorch from source.
    !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

                                  !! WARNING !!

      warnings.warn(WRONG_COMPILER_WARNING.format(
    [1/5] c++ -MMD -MF /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.o.d -pthread -B /home/steadysjtu/anaconda3/envs/detectron2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/steadysjtu/projects/detectron2/detectron2/layers/csrc -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/TH -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-9.0/include -I/home/steadysjtu/anaconda3/envs/detectron2/include/python3.8 -c -c /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.cpp -o /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    FAILED: /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.o
    c++ -MMD -MF /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.o.d -pthread -B /home/steadysjtu/anaconda3/envs/detectron2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/steadysjtu/projects/detectron2/detectron2/layers/csrc -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/TH -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-9.0/include -I/home/steadysjtu/anaconda3/envs/detectron2/include/python3.8 -c -c /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.cpp -o /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    cc1plus: 警告:command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/ATen/ATen.h:7:0,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/types.h:3,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated.h:3,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/box_iou_rotated/box_iou_rotated_cpu.cpp:2:
    /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/c10/core/Allocator.h:3:10: 致命错误:stddef.h:没有那个文件或目录
     #include <stddef.h>
              ^~~~~~~~~~
    编译中断。
    [2/5] c++ -MMD -MF /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o.d -pthread -B /home/steadysjtu/anaconda3/envs/detectron2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/steadysjtu/projects/detectron2/detectron2/layers/csrc -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/TH -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-9.0/include -I/home/steadysjtu/anaconda3/envs/detectron2/include/python3.8 -c -c /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp -o /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    FAILED: /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o
    c++ -MMD -MF /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o.d -pthread -B /home/steadysjtu/anaconda3/envs/detectron2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/steadysjtu/projects/detectron2/detectron2/layers/csrc -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/TH -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-9.0/include -I/home/steadysjtu/anaconda3/envs/detectron2/include/python3.8 -c -c /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp -o /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    cc1plus: 警告:command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from /home/steadysjtu/anaconda3/envs/detectron2/include/python3.8/Python.h:11:0,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/detail/common.h:122,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/pytypes.h:12,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/cast.h:13,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/attr.h:13,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/pybind11.h:45,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/numpy.h:12,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.h:4,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp:2:
    /usr/include/limits.h:124:26: 错误:没有包含路径可供搜索 limits.h
     # include_next <limits.h>
                              ^
    In file included from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/detail/common.h:122:0,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/pytypes.h:12,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/cast.h:13,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/attr.h:13,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/pybind11.h:45,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/numpy.h:12,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.h:4,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp:2:
    /home/steadysjtu/anaconda3/envs/detectron2/include/python3.8/Python.h:14:2: 错误:#error "Something's broken.  UCHAR_MAX should be defined in limits.h."
     #error "Something's broken.  UCHAR_MAX should be defined in limits.h."
      ^~~~~
    /home/steadysjtu/anaconda3/envs/detectron2/include/python3.8/Python.h:18:2: 错误:#error "Python's source code assumes C's unsigned char is an 8-bit type."
     #error "Python's source code assumes C's unsigned char is an 8-bit type."
      ^~~~~
    In file included from /home/steadysjtu/anaconda3/envs/detectron2/include/python3.8/Python.h:25:0,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/detail/common.h:122,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/pytypes.h:12,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/cast.h:13,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/attr.h:13,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/pybind11.h:45,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/pybind11/numpy.h:12,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.h:4,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp:2:
    /usr/include/stdio.h:33:10: 致命错误:stddef.h:没有那个文件或目录
     #include <stddef.h>
              ^~~~~~~~~~
    编译中断。
    [3/5] c++ -MMD -MF /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.o.d -pthread -B /home/steadysjtu/anaconda3/envs/detectron2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/steadysjtu/projects/detectron2/detectron2/layers/csrc -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/TH -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-9.0/include -I/home/steadysjtu/anaconda3/envs/detectron2/include/python3.8 -c -c /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.cpp -o /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    FAILED: /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.o
    c++ -MMD -MF /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.o.d -pthread -B /home/steadysjtu/anaconda3/envs/detectron2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/steadysjtu/projects/detectron2/detectron2/layers/csrc -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/TH -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-9.0/include -I/home/steadysjtu/anaconda3/envs/detectron2/include/python3.8 -c -c /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.cpp -o /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    cc1plus: 警告:command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from /usr/local/include/c++/7.5.0/cwchar:44:0,
                     from /usr/local/include/c++/7.5.0/bits/postypes.h:40,
                     from /usr/local/include/c++/7.5.0/iosfwd:40,
                     from /usr/local/include/c++/7.5.0/ios:38,
                     from /usr/local/include/c++/7.5.0/istream:38,
                     from /usr/local/include/c++/7.5.0/sstream:38,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/c10/macros/Macros.h:187,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/c10/core/DeviceType.h:8,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/c10/core/Device.h:3,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/ATen/core/TensorBody.h:3,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/ATen/Tensor.h:3,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/ATen/TensorUtils.h:3,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/ROIAlignRotated/ROIAlignRotated_cpu.cpp:2:
    /usr/include/wchar.h:35:10: 致命错误:stddef.h:没有那个文件或目录
     #include <stddef.h>
              ^~~~~~~~~~
    编译中断。
    [4/5] c++ -MMD -MF /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/vision.o.d -pthread -B /home/steadysjtu/anaconda3/envs/detectron2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/steadysjtu/projects/detectron2/detectron2/layers/csrc -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/TH -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-9.0/include -I/home/steadysjtu/anaconda3/envs/detectron2/include/python3.8 -c -c /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/vision.cpp -o /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/vision.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    FAILED: /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/vision.o
    c++ -MMD -MF /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/vision.o.d -pthread -B /home/steadysjtu/anaconda3/envs/detectron2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/steadysjtu/projects/detectron2/detectron2/layers/csrc -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/TH -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-9.0/include -I/home/steadysjtu/anaconda3/envs/detectron2/include/python3.8 -c -c /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/vision.cpp -o /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/vision.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    cc1plus: 警告:command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/cuda.h:6:0,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include/torch/all.h:7,
                     from /home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/extension.h:4,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/vision.cpp:3:
    /usr/local/include/c++/7.5.0/cstddef:50:10: 致命错误:stddef.h:没有那个文件或目录
     #include <stddef.h>
              ^~~~~~~~~~
    编译中断。
    [5/5] c++ -MMD -MF /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.o.d -pthread -B /home/steadysjtu/anaconda3/envs/detectron2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/steadysjtu/projects/detectron2/detectron2/layers/csrc -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/TH -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-9.0/include -I/home/steadysjtu/anaconda3/envs/detectron2/include/python3.8 -c -c /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.cpp -o /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    FAILED: /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.o
    c++ -MMD -MF /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.o.d -pthread -B /home/steadysjtu/anaconda3/envs/detectron2/compiler_compat -Wl,--sysroot=/ -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -DWITH_CUDA -I/home/steadysjtu/projects/detectron2/detectron2/layers/csrc -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/torch/csrc/api/include -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/TH -I/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/include/THC -I/usr/local/cuda-9.0/include -I/home/steadysjtu/anaconda3/envs/detectron2/include/python3.8 -c -c /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.cpp -o /home/steadysjtu/projects/detectron2/build/temp.linux-x86_64-3.8/home/steadysjtu/projects/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1011"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=0 -std=c++14
    cc1plus: 警告:command line option ‘-Wstrict-prototypes’ is valid for C/ObjC but not for C++
    In file included from /usr/local/include/c++/7.5.0/bits/std_abs.h:38:0,
                     from /usr/local/include/c++/7.5.0/cmath:47,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/nms_rotated/../box_iou_rotated/box_iou_rotated_utils.h:5,
                     from /home/steadysjtu/projects/detectron2/detectron2/layers/csrc/nms_rotated/nms_rotated_cpu.cpp:2:
    /usr/include/stdlib.h:31:10: 致命错误:stddef.h:没有那个文件或目录
     #include <stddef.h>
              ^~~~~~~~~~
    编译中断。
    ninja: build stopped: subcommand failed.
    Traceback (most recent call last):
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1533, in _run_ninja_build
        subprocess.run(
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/subprocess.py", line 516, in run
        raise CalledProcessError(retcode, process.args,
    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 "<string>", line 1, in <module>
      File "/home/steadysjtu/projects/detectron2/setup.py", line 193, in <module>
        setup(
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/setuptools/__init__.py", line 153, in setup
        return distutils.core.setup(**attrs)
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/distutils/core.py", line 148, in setup
        dist.run_commands()
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/distutils/dist.py", line 966, in run_commands
        self.run_command(cmd)
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/setuptools/command/develop.py", line 34, in run
        self.install_for_development()
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/setuptools/command/develop.py", line 136, in install_for_development
        self.run_command('build_ext')
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/distutils/cmd.py", line 313, in run_command
        self.distribution.run_command(command)
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/distutils/dist.py", line 985, in run_command
        cmd_obj.run()
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 79, in run
        _build_ext.run(self)
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 186, in run
        _build_ext.build_ext.run(self)
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/distutils/command/build_ext.py", line 340, in run
        self.build_extensions()
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 670, in build_extensions
        build_ext.build_extensions(self)
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/Cython/Distutils/old_build_ext.py", line 195, in build_extensions
        _build_ext.build_ext.build_extensions(self)
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/distutils/command/build_ext.py", line 449, in build_extensions
        self._build_extensions_serial()
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/distutils/command/build_ext.py", line 474, in _build_extensions_serial
        self.build_extension(ext)
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/setuptools/command/build_ext.py", line 196, in build_extension
        _build_ext.build_extension(self, ext)
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/distutils/command/build_ext.py", line 528, in build_extension
        objects = self.compiler.compile(sources,
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 491, in unix_wrap_ninja_compile
        _write_ninja_file_and_compile_objects(
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1250, in _write_ninja_file_and_compile_objects
        _run_ninja_build(
      File "/home/steadysjtu/anaconda3/envs/detectron2/lib/python3.8/site-packages/torch/utils/cpp_extension.py", line 1555, in _run_ninja_build
        raise RuntimeError(message) from e
    RuntimeError: Error compiling objects for extension
    ----------------------------------------
ERROR: Command errored out with exit status 1: /home/steadysjtu/anaconda3/envs/detectron2/bin/python -c 'import io, os, sys, setuptools, tokenize; sys.argv[0] = '"'"'/home/steadysjtu/projects/detectron2/setup.py'"'"'; __file__='"'"'/home/steadysjtu/projects/detectron2/setup.py'"'"';f = getattr(tokenize, '"'"'open'"'"', open)(__file__) if os.path.exists(__file__) else io.StringIO('"'"'from setuptools import setup; setup()'"'"');code = f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' develop --no-deps Check the logs for full command output.

我使用的是ubuntu16.04。我参考了这个答案,但它对我不起作用。 安装 python 模块失败 - “limits.h”丢失? 谁能帮我?

答案1

此错误消息回答了您的问题

您的编译器 (c++) 与为此平台构建 Pytorch 的编译器(Linux 上的 g++)不兼容。请使用 g++ 来编译您的扩展。

安装并使用g++而不是c++

相关内容