Open EdibHamzaArslan opened 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.
apt-get update && apt-get -y install pybind11-dev
this fixed the issue for me.
Thank you, pybind was the culprit π
apt-get update && apt-get -y install pybind11-dev
this fixed the issue for me.
This really helps. Thanks a lot.
same issue remains on windows 10, even after installing pybind
-- 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.
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
For me it also worked to install pybind11 and pybind11-global in my conda environment:
conda install pybind11
Solved on Windows with python=3.9 torch=2.1 cuda=11.8
conda install -c conda-forge pybind11
cd <Path-to-conda-env>/include
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".
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'
Instructions To Reproduce the π Bug:
Full logs or other relevant observations:
Γ 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.note: This error originates from a subprocess, and is likely not a problem with pip.
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: