facebookresearch / detectron2

Detectron2 is a platform for object detection, segmentation and other visual recognition tasks.
https://detectron2.readthedocs.io/en/latest/
Apache License 2.0
30.47k stars 7.48k forks source link

Detectron2 installation error on Python 3.9 #4748

Open EdibHamzaArslan opened 1 year ago

EdibHamzaArslan commented 1 year ago

Instructions To Reproduce the πŸ› Bug:

  1. Full runnable code or full changes you made: I didn't change anything. I have another conda enviroment in my machine, and I successfully installed detectron2 on this enviroment, the only difference is that this enviroment is using python 3.8.
  2. What exact command you run: python -m pip install -e detectron2 or python -m pip install 'git+https://github.com/facebookresearch/detectron2.git'
  3. Full logs or other relevant observations:

    
    Installing collected packages: detectron2
    Running setup.py develop for detectron2
    error: subprocess-exited-with-error
    
    Γ— python setup.py develop did not run successfully.
    β”‚ exit code: 1
    ╰─> [94 lines of output]
        running develop
        /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/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(
        /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
          warnings.warn(
        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'
        adding license file 'LICENSE'
        writing manifest file 'detectron2.egg-info/SOURCES.txt'
        running build_ext
        building 'detectron2._C' extension
        Emitting ninja build file /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/build.ninja...
        Compiling objects...
        Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N)
        [1/2] c++ -MMD -MF /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o.d -pthread -B /home/edib_hamza/anaconda3/envs/pytorch3d/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -DWITH_CUDA -I/home/edib_hamza/projects/detectron2/detectron2/layers/csrc -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/TH -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/THC -I/usr/local/cuda-11.3/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include/python3.9 -c -c /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp -o /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1013"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
        FAILED: /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o
        c++ -MMD -MF /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o.d -pthread -B /home/edib_hamza/anaconda3/envs/pytorch3d/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -DWITH_CUDA -I/home/edib_hamza/projects/detectron2/detectron2/layers/csrc -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/TH -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/THC -I/usr/local/cuda-11.3/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include/python3.9 -c -c /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp -o /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1013"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
        In file included from /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp:2:
        /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.h:4:10: fatal error: pybind11/numpy.h: No such file or directory
            4 | #include <pybind11/numpy.h>
              |          ^~~~~~~~~~~~~~~~~~
        compilation terminated.
        [2/2] c++ -MMD -MF /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.o.d -pthread -B /home/edib_hamza/anaconda3/envs/pytorch3d/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -DWITH_CUDA -I/home/edib_hamza/projects/detectron2/detectron2/layers/csrc -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/TH -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/THC -I/usr/local/cuda-11.3/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include/python3.9 -c -c /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.cpp -o /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1013"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
        FAILED: /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.o
        c++ -MMD -MF /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.o.d -pthread -B /home/edib_hamza/anaconda3/envs/pytorch3d/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -DWITH_CUDA -I/home/edib_hamza/projects/detectron2/detectron2/layers/csrc -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/TH -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/THC -I/usr/local/cuda-11.3/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include/python3.9 -c -c /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.cpp -o /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1013"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14
        In file included from /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/api/include/torch/python.h:12,
                         from /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/extension.h:6,
                         from /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.cpp:3:
        /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/utils/pybind.h:7:10: fatal error: pybind11/pybind11.h: No such file or directory
            7 | #include <pybind11/pybind11.h>
              |          ^~~~~~~~~~~~~~~~~~~~~
        compilation terminated.
        ninja: build stopped: subcommand failed.
        Traceback (most recent call last):
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1813, in _run_ninja_build
            subprocess.run(
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/subprocess.py", line 528, 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 2, in <module>
          File "<pip-setuptools-caller>", line 34, in <module>
          File "/home/edib_hamza/projects/detectron2/setup.py", line 148, in <module>
            setup(
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/__init__.py", line 87, in setup
            return distutils.core.setup(**attrs)
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
            return run_commands(dist)
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
            dist.run_commands()
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
            self.run_command(cmd)
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
            super().run_command(command)
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
            cmd_obj.run()
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/command/develop.py", line 34, in run
            self.install_for_development()
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/command/develop.py", line 114, in install_for_development
            self.run_command('build_ext')
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
            self.distribution.run_command(command)
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
            super().run_command(command)
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
            cmd_obj.run()
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 84, in run
            _build_ext.run(self)
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
            self.build_extensions()
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 770, in build_extensions
            build_ext.build_extensions(self)
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 468, in build_extensions
            self._build_extensions_serial()
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 494, in _build_extensions_serial
            self.build_extension(ext)
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
            _build_ext.build_extension(self, ext)
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 549, in build_extension
            objects = self.compiler.compile(
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 591, in unix_wrap_ninja_compile
            _write_ninja_file_and_compile_objects(
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1492, in _write_ninja_file_and_compile_objects
            _run_ninja_build(
          File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1829, in _run_ninja_build
            raise RuntimeError(message) from e
        RuntimeError: Error compiling objects for extension
        [end of output]
    
    note: This error originates from a subprocess, and is likely not a problem with pip.
    error: subprocess-exited-with-error

Γ— python setup.py develop did not run successfully. β”‚ exit code: 1 ╰─> [94 lines of output] running develop /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/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( /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/command/install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools. warnings.warn( 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' adding license file 'LICENSE' writing manifest file 'detectron2.egg-info/SOURCES.txt' running build_ext building 'detectron2._C' extension Emitting ninja build file /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/build.ninja... Compiling objects... Allowing ninja to set a default number of workers... (overridable by setting the environment variable MAX_JOBS=N) [1/2] c++ -MMD -MF /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o.d -pthread -B /home/edib_hamza/anaconda3/envs/pytorch3d/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -DWITH_CUDA -I/home/edib_hamza/projects/detectron2/detectron2/layers/csrc -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/TH -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/THC -I/usr/local/cuda-11.3/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include/python3.9 -c -c /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp -o /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1013"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14 FAILED: /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o c++ -MMD -MF /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o.d -pthread -B /home/edib_hamza/anaconda3/envs/pytorch3d/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -DWITH_CUDA -I/home/edib_hamza/projects/detectron2/detectron2/layers/csrc -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/TH -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/THC -I/usr/local/cuda-11.3/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include/python3.9 -c -c /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp -o /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1013"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14 In file included from /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.cpp:2: /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/cocoeval/cocoeval.h:4:10: fatal error: pybind11/numpy.h: No such file or directory 4 | #include <pybind11/numpy.h> | ^~~~~~ compilation terminated. [2/2] c++ -MMD -MF /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.o.d -pthread -B /home/edib_hamza/anaconda3/envs/pytorch3d/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -DWITH_CUDA -I/home/edib_hamza/projects/detectron2/detectron2/layers/csrc -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/TH -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/THC -I/usr/local/cuda-11.3/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include/python3.9 -c -c /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.cpp -o /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1013"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14 FAILED: /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.o c++ -MMD -MF /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.o.d -pthread -B /home/edib_hamza/anaconda3/envs/pytorch3d/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -O2 -Wall -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -O2 -isystem /home/edib_hamza/anaconda3/envs/pytorch3d/include -fPIC -DWITH_CUDA -I/home/edib_hamza/projects/detectron2/detectron2/layers/csrc -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/api/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/TH -I/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/THC -I/usr/local/cuda-11.3/include -I/home/edib_hamza/anaconda3/envs/pytorch3d/include/python3.9 -c -c /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.cpp -o /home/edib_hamza/projects/detectron2/build/temp.linux-x86_64-cpython-39/home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.o -DTORCH_API_INCLUDE_EXTENSION_H '-DPYBIND11_COMPILER_TYPE="_gcc"' '-DPYBIND11_STDLIB="_libstdcpp"' '-DPYBIND11_BUILD_ABI="_cxxabi1013"' -DTORCH_EXTENSION_NAME=_C -D_GLIBCXX_USE_CXX11_ABI=1 -std=c++14 In file included from /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/api/include/torch/python.h:12, from /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/extension.h:6, from /home/edib_hamza/projects/detectron2/detectron2/layers/csrc/vision.cpp:3: /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/include/torch/csrc/utils/pybind.h:7:10: fatal error: pybind11/pybind11.h: No such file or directory 7 | #include <pybind11/pybind11.h> | ^~~~~ compilation terminated. ninja: build stopped: subcommand failed. Traceback (most recent call last): File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1813, in _run_ninja_build subprocess.run( File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/subprocess.py", line 528, 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 2, in <module>
  File "<pip-setuptools-caller>", line 34, in <module>
  File "/home/edib_hamza/projects/detectron2/setup.py", line 148, in <module>
    setup(
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/__init__.py", line 87, in setup
    return distutils.core.setup(**attrs)
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 185, in setup
    return run_commands(dist)
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/core.py", line 201, in run_commands
    dist.run_commands()
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 969, in run_commands
    self.run_command(cmd)
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
    super().run_command(command)
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/command/develop.py", line 34, in run
    self.install_for_development()
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/command/develop.py", line 114, in install_for_development
    self.run_command('build_ext')
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/cmd.py", line 318, in run_command
    self.distribution.run_command(command)
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/dist.py", line 1208, in run_command
    super().run_command(command)
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/dist.py", line 988, in run_command
    cmd_obj.run()
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 84, in run
    _build_ext.run(self)
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 346, in run
    self.build_extensions()
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 770, in build_extensions
    build_ext.build_extensions(self)
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 468, in build_extensions
    self._build_extensions_serial()
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 494, in _build_extensions_serial
    self.build_extension(ext)
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/command/build_ext.py", line 246, in build_extension
    _build_ext.build_extension(self, ext)
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/setuptools/_distutils/command/build_ext.py", line 549, in build_extension
    objects = self.compiler.compile(
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 591, in unix_wrap_ninja_compile
    _write_ninja_file_and_compile_objects(
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1492, in _write_ninja_file_and_compile_objects
    _run_ninja_build(
  File "/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch/utils/cpp_extension.py", line 1829, in _run_ninja_build
    raise RuntimeError(message) from e
RuntimeError: Error compiling objects for extension
[end of output]

note: This error originates from a subprocess, and is likely not a problem with pip.


## Environment:

Provide your environment information using the following command:

cuobjdump info : File '/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torchvision/_C.so' does not contain device code


sys.platform linux Python 3.9.16 (main, Jan 11 2023, 16:05:54) [GCC 11.2.0] numpy 1.23.5 detectron2 imported a wrong installation detectron2._C not built correctly: No module named 'detectron2._C' Compiler ($CXX) c++ (Ubuntu 10.3.0-1ubuntu1~20.04) 10.3.0 CUDA compiler Build cuda_11.3.r11.3/compiler.29745058_0 DETECTRON2_ENV_MODULE PyTorch 1.12.1 @/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torch PyTorch debug build False GPU available Yes GPU 0 NVIDIA GeForce GTX 1050 Ti (arch=6.1) Driver version 510.85.02 CUDA_HOME /usr/local/cuda-11.3 Pillow 9.3.0 torchvision 0.13.1a0 @/home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torchvision torchvision arch flags /home/edib_hamza/anaconda3/envs/pytorch3d/lib/python3.9/site-packages/torchvision/_C.so fvcore 0.1.5.post20221221 iopath 0.1.9 cv2 4.7.0


PyTorch built with:

EdibHamzaArslan commented 1 year ago

Hey, I created new env with python=3.8.5 but I didn't fix it. Before install detectron2, I installed this packages:

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=11.3 -c pytorch
conda install -c fvcore -c iopath -c conda-forge fvcore iopath
conda install -c bottler nvidiacub
conda install jupyter
pip install scikit-image matplotlib imageio plotly opencv-python
pip install black usort flake8 flake8-bugbear flake8-comprehensions
conda install pytorch3d -c pytorch3d

After that I am running this command "python -m pip install 'git+https://github.com/facebookresearch/detectron2.git' " I get same error.

nikhilaravi commented 1 year ago

apt-get update && apt-get -y install pybind11-dev this fixed the issue for me.

arthurgervais commented 1 year ago

Thank you, pybind was the culprit πŸ‘

linyaaaa commented 1 year ago

apt-get update && apt-get -y install pybind11-dev this fixed the issue for me.

This really helps. Thanks a lot.

SaadAhmad376 commented 12 months ago

same issue remains on windows 10, even after installing pybind

zyqhnu commented 10 months ago

-- 2023.12.19 16:00:00 -- I got the same error! Unfortunately, I don't have access to upgrade pybind11-dev.

-- update on 2023.12.20 10.13 -- I change the python version from 3.9.18 to 3.9.0, and it installed successfully.

Ayush-Nema commented 7 months ago

I faced the same issue while installing detectron2 in EC2 instance (Amazon Linux image). Despite of running $ sudo yum update && sudo yum -y install pybind11-devel, the failure persisted. Found that the Python header files are missing, which are necessary for compiling the Detectron2 package. Running $ sudo yum install python3-devel helped!

In summary, run the following: $ sudo yum update && sudo yum -y install pybind11-devel $ sudo yum install python3-devel

MouvementMondial commented 7 months ago

For me it also worked to install pybind11 and pybind11-global in my conda environment: conda install pybind11

maxrohleder commented 6 months ago

Solved on Windows with python=3.9 torch=2.1 cuda=11.8

  1. Install pybind: conda install -c conda-forge pybind11
  2. Navigate to your conda env include directory cd <Path-to-conda-env>/include
  3. There should be a folder named "pybind11_global" with a folder "pybind11" inside...
  4. Move the "ybind11" folder next to its current parent dir "pybind11_global" and remove the now empty directory
  5. Now re-run the install script python -m pip install -e detectron2

The problem is, that the detectron2 build script looks for "pybind11/pybind11.h" in your env/include directory. The latest version of pybind11 however installs this intermediate directory named "pybind11_global".

miquel-espinosa commented 6 months ago

I found extremely tricky to get all the dependencies right. So I am leaving here the instructions to set up the environment.

# Create conda env
conda create --name detectron2 python==3.9 -y
conda activate matcher

# Install torch
pip install torch torchvision

# Install gcc and g++ with conda 
conda install -c conda-forge pybind11
conda install -c conda-forge gxx
conda install -c anaconda gcc_linux-64
conda upgrade -c conda-forge --all

# Install detectron2 (specific version)
pip install 'git+https://github.com/facebookresearch/detectron2.git@v0.6'