Skip to content

fatal error: Python.h: No such file or directory #618

@DrRyanHuang

Description

@DrRyanHuang

I follow the instrucion:
https://github.com/open-mmlab/mmdeploy/blob/master/docs/zh_cn/01-how-to-build/linux-x86_64.md

However, When I run:

cd ${MMDEPLOY_DIR}
mkdir -p build && cd build
cmake .. \
    -DCMAKE_CXX_COMPILER=g++-7 \
    -DMMDEPLOY_BUILD_SDK=ON \
    -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON \
    -DMMDEPLOY_TARGET_DEVICES="cuda;cpu" \
    -DMMDEPLOY_TARGET_BACKENDS=trt \
    -DMMDEPLOY_CODEBASES=all \
    -Dpplcv_DIR=${PPLCV_DIR}/cuda-build/install/lib/cmake/ppl \
    -DTENSORRT_DIR=${TENSORRT_DIR} \
    -DCUDNN_DIR=${CUDNN_DIR}

make -j$(nproc) && make -install

I encounter this:

(open-mmlab) ryan@xx:~/code/mmdeploy-master/build$ cmake .. \
>     -DCMAKE_CXX_COMPILER=g++-7 \
>     -DMMDEPLOY_BUILD_SDK=ON \
>     -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON \
>     -DMMDEPLOY_TARGET_DEVICES="cuda;cpu" \
>     -DMMDEPLOY_TARGET_BACKENDS=trt \
>     -DMMDEPLOY_CODEBASES=all \
>     -Dpplcv_DIR=${PPLCV_DIR}/cuda-build/install/lib/cmake/ppl \
>     -DTENSORRT_DIR=${TENSORRT_DIR} \
>     -DCUDNN_DIR=${CUDNN_DIR}
-- CMAKE_INSTALL_PREFIX: /home/ryan/code/mmdeploy-master/build/install
-- Build TensorRT custom ops.
-- Found TensorRT headers at /home/ryan/Downloads/TensorRT-8.4.1.5/include
-- Found TensorRT libs at /home/ryan/Downloads/TensorRT-8.4.1.5/lib/libnvinfer.so;/home/ryan/Downloads/TensorRT-8.4.1.5/lib/libnvinfer_plugin.so
-- Build spdlog: 1.10.0
-- Build type: Release
-- Found TensorRT headers at /home/ryan/Downloads/TensorRT-8.4.1.5/include
-- Found TensorRT libs at /home/ryan/Downloads/TensorRT-8.4.1.5/lib/libnvinfer.so;/home/ryan/Downloads/TensorRT-8.4.1.5/lib/libnvinfer_plugin.so
-- build codebase: mmcls
-- build codebase: mmdet
-- build codebase: mmseg
-- build codebase: mmocr
-- build codebase: mmedit
-- build codebase: mmpose
-- build codebase: mmrotate
-- pybind11 v2.9.0 dev1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/ryan/code/mmdeploy-master/build
ryan@STEAM:~/code/mmdeploy-master/build$ make -j$(nproc) && make -install
Consolidate compiler generated dependencies of target spdlog
Consolidate compiler generated dependencies of target mmdeploy_tensorrt_ops_obj
[  5%] Built target spdlog
Consolidate compiler generated dependencies of target mmdeploy_core
[ 20%] Built target mmdeploy_tensorrt_ops_obj
[ 20%] Built target mmdeploy_tensorrt_ops
[ 28%] Built target mmdeploy_core
Consolidate compiler generated dependencies of target mmdeploy_opencv_utils
Consolidate compiler generated dependencies of target mmdeploy_cpu_device
Consolidate compiler generated dependencies of target mmdeploy_execution
Consolidate compiler generated dependencies of target mmdeploy_cuda_device
[ 29%] Built target mmdeploy_execution
[ 30%] Built target mmdeploy_cpu_device
[ 31%] Built target mmdeploy_opencv_utils
[ 33%] Built target mmdeploy_cuda_device
Consolidate compiler generated dependencies of target mmdeploy_graph
Consolidate compiler generated dependencies of target mmdeploy_directory_model
Consolidate compiler generated dependencies of target mmdeploy_transform
Consolidate compiler generated dependencies of target mmdeploy_net_module
[ 37%] Built target mmdeploy_graph
[ 39%] Built target mmdeploy_net_module
[ 41%] Built target mmdeploy_directory_model
Consolidate compiler generated dependencies of target mmdeploy_trt_net
Consolidate compiler generated dependencies of target mmdeploy_mmcls
Consolidate compiler generated dependencies of target mmdeploy_mmdet
[ 47%] Built target mmdeploy_transform
[ 48%] Built target mmdeploy_trt_net
[ 49%] Built target mmdeploy_mmcls
Consolidate compiler generated dependencies of target mmdeploy_mmseg
[ 52%] Built target mmdeploy_mmdet
Consolidate compiler generated dependencies of target mmdeploy_mmocr_cpu_impl
[ 53%] Built target mmdeploy_mmseg
Consolidate compiler generated dependencies of target mmdeploy_mmocr_cuda_impl
Consolidate compiler generated dependencies of target mmdeploy_mmedit
Consolidate compiler generated dependencies of target mmdeploy_mmpose
[ 55%] Built target mmdeploy_mmocr_cpu_impl
[ 56%] Built target mmdeploy_mmedit
[ 59%] Built target mmdeploy_mmocr_cuda_impl
Consolidate compiler generated dependencies of target mmdeploy_mmrotate
Consolidate compiler generated dependencies of target mmdeploy_model
Consolidate compiler generated dependencies of target mmdeploy_common
[ 60%] Built target mmdeploy_model
[ 65%] Built target mmdeploy_mmrotate
[ 65%] Built target mmdeploy_mmpose
[ 66%] Built target mmdeploy_common
Consolidate compiler generated dependencies of target mmdeploy_transform_module
Consolidate compiler generated dependencies of target mmdeploy_cuda_transform_impl
Consolidate compiler generated dependencies of target mmdeploy_mmocr
[ 67%] Built target mmdeploy_transform_module
Consolidate compiler generated dependencies of target mmdeploy_cpu_transform_impl
Consolidate compiler generated dependencies of target mmdeploy_executor
[ 68%] Built target mmdeploy_executor
[ 74%] Built target mmdeploy_mmocr
[ 80%] Built target mmdeploy_cuda_transform_impl
Consolidate compiler generated dependencies of target mmdeploy_pipeline
[ 85%] Built target mmdeploy_cpu_transform_impl
[ 86%] Built target mmdeploy_pipeline
Consolidate compiler generated dependencies of target mmdeploy_detector
Consolidate compiler generated dependencies of target mmdeploy_rotated_detector
Consolidate compiler generated dependencies of target mmdeploy_restorer
Consolidate compiler generated dependencies of target mmdeploy_text_detector
[ 88%] Built target mmdeploy_rotated_detector
[ 89%] Built target mmdeploy_detector
[ 90%] Built target mmdeploy_restorer
[ 91%] Built target mmdeploy_text_detector
Consolidate compiler generated dependencies of target mmdeploy_pose_detector
Consolidate compiler generated dependencies of target mmdeploy_text_recognizer
Consolidate compiler generated dependencies of target mmdeploy_segmentor
Consolidate compiler generated dependencies of target mmdeploy_classifier
[ 92%] Built target mmdeploy_pose_detector
[ 93%] Built target mmdeploy_text_recognizer
[ 94%] Built target mmdeploy_segmentor
[ 95%] Built target mmdeploy_classifier
[ 95%] Building CXX object csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/common.cpp.o
[ 96%] Building CXX object csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/detector.cpp.o
[ 96%] Building CXX object csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/classifier.cpp.o
[ 97%] Building CXX object csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/segmentor.cpp.o
In file included from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/pytypes.h:12:0,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/cast.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/attr.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/pybind11.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/numpy.h:12,
                 from /home/ryan/code/mmdeploy-master/csrc/mmdeploy/apis/python/common.h:9,
                 from /home/ryan/code/mmdeploy-master/csrc/mmdeploy/apis/python/classifier.cpp:5:
/home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/detail/common.h:186:10: fatal error: Python.h: No such file or directory
 #include <Python.h>
          ^~~~~~~~~~
compilation terminated.
csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/build.make:89: recipe for target 'csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/classifier.cpp.o' failed
make[2]: *** [csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/classifier.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/pytypes.h:12:0,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/cast.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/attr.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/pybind11.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/numpy.h:12,
                 from /home/ryan/code/mmdeploy-master/csrc/mmdeploy/apis/python/common.h:9,
                 from /home/ryan/code/mmdeploy-master/csrc/mmdeploy/apis/python/common.cpp:3:
/home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/detail/common.h:186:10: fatal error: Python.h: No such file or directory
 #include <Python.h>
          ^~~~~~~~~~
compilation terminated.
csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/build.make:75: recipe for target 'csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/common.cpp.o' failed
make[2]: *** [csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/common.cpp.o] Error 1
In file included from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/pytypes.h:12:0,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/cast.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/attr.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/pybind11.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/numpy.h:12,
                 from /home/ryan/code/mmdeploy-master/csrc/mmdeploy/apis/python/common.h:9,
                 from /home/ryan/code/mmdeploy-master/csrc/mmdeploy/apis/python/detector.cpp:5:
/home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/detail/common.h:186:10: fatal error: Python.h: No such file or directory
 #include <Python.h>
          ^~~~~~~~~~
compilation terminated.
csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/build.make:103: recipe for target 'csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/detector.cpp.o' failed
make[2]: *** [csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/detector.cpp.o] Error 1
In file included from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/pytypes.h:12:0,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/cast.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/attr.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/pybind11.h:13,
                 from /home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/numpy.h:12,
                 from /home/ryan/code/mmdeploy-master/csrc/mmdeploy/apis/python/common.h:9,
                 from /home/ryan/code/mmdeploy-master/csrc/mmdeploy/apis/python/segmentor.cpp:5:
/home/ryan/code/mmdeploy-master/third_party/pybind11/include/pybind11/detail/common.h:186:10: fatal error: Python.h: No such file or directory
 #include <Python.h>
          ^~~~~~~~~~
compilation terminated.
csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/build.make:117: recipe for target 'csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/segmentor.cpp.o' failed
make[2]: *** [csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/segmentor.cpp.o] Error 1
CMakeFiles/Makefile2:1755: recipe for target 'csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/all' failed
make[1]: *** [csrc/mmdeploy/apis/python/CMakeFiles/mmdeploy_python.dir/all] Error 2
Makefile:135: recipe for target 'all' failed
make: *** [all] Error 2

My $LD_LIBRARY_PATH:

/home/ryan/Public/miniconda3/envs/open-mmlab/include/python3.7m:
/home/ryan/Downloads/onnxruntime-linux-x64-1.8.1/lib:
/home/ryan/Downloads/TensorRT-8.4.1.5/lib:
/home/ryan/Downloads/cudnn-linux-x86_64-8.4.1.50_cuda10.2-archive/lib64:
/usr/local/cuda/lib:

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions