Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Detectron2 installation error on Python 3.9 #4748

Open
EdibHamzaArslan opened this issue Jan 18, 2023 · 10 comments
Open

Detectron2 installation error on Python 3.9 #4748

EdibHamzaArslan opened this issue Jan 18, 2023 · 10 comments

Comments

@EdibHamzaArslan
Copy link

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   <not set>
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:
  - GCC 9.3
  - C++ Version: 201402
  - Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications
  - Intel(R) MKL-DNN v2.6.0 (Git Hash N/A)
  - OpenMP 201511 (a.k.a. OpenMP 4.5)
  - LAPACK is enabled (usually provided by MKL)
  - NNPACK is enabled
  - CPU capability usage: AVX2
  - CUDA Runtime 11.3
  - NVCC architecture flags: -gencode;arch=compute_35,code=sm_35;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_61,code=sm_61;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_86,code=compute_86
  - CuDNN 8.2.1
  - Magma 2.7.0
  - Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.3, CUDNN_VERSION=8.2.1, CXX_COMPILER=/home/builder/mc3/envs/pytorch-build/envs/pytorch-build/conda-bld/pytorch_1673601922403/_build_env/bin/x86_64-conda-linux-gnu-c++, CXX_FLAGS=-fvisibility-inlines-hidden  -fmessage-length=0 -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-protector-strong -fno-plt -O2 -ffunction-sections -pipe -isystem /home/builder/mc3/envs/pytorch-build/envs/pytorch-build/conda-bld/pytorch_1673601922403/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_/include -fdebug-prefix-map=/home/builder/mc3/envs/pytorch-build/envs/pytorch-build/conda-bld/pytorch_1673601922403/work=/usr/local/src/conda/pytorch-1.12.1 -fdebug-prefix-map=/home/builder/mc3/envs/pytorch-build/envs/pytorch-build/conda-bld/pytorch_1673601922403/_h_env_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_placehold_=/usr/local/src/conda-prefix -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -fopenmp -DNDEBUG -DUSE_KINETO -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -DEDGE_PROFILER_USE_KINETO -O2 -fPIC -Wno-narrowing -Wall -Wextra -Werror=return-type -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-unused-local-typedefs -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_VERSION=1.12.1, USE_CUDA=1, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MPI=OFF, USE_NCCL=ON, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,
@EdibHamzaArslan
Copy link
Author

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
Copy link

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

@arthurgervais
Copy link

Thank you, pybind was the culprit 👍

@linyaaaa
Copy link

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

This really helps. Thanks a lot.

@SaadAhmad376
Copy link

same issue remains on windows 10, even after installing pybind

@zyqhnu
Copy link

zyqhnu commented Dec 19, 2023

-- 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
Copy link

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
Copy link

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

@maxrohleder
Copy link

maxrohleder commented Apr 23, 2024

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
Copy link

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'

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

No branches or pull requests

10 participants