Closed zzxaijs closed 2 years ago
Could you share your command to build SDK?
The build option MMDEPLOY_BUILD_SDK
must be turned by -DMMDEPLOY_BUILD_SDK=ON
Besides, MMDEPLOY_CODEBASES
and MMDEPLOY_TARGET_BACKENDS
have to be specified.
Could you share your command to build SDK?
The build option
MMDEPLOY_BUILD_SDK
must be turned by-DMMDEPLOY_BUILD_SDK=ON
Besides,
MMDEPLOY_CODEBASES
andMMDEPLOY_TARGET_BACKENDS
have to be specified.
my command as followwing
cmake .. -DMMDEPLOY_BUILD_SDK=ON -DCMAKE_CXX_COMPILER=g++-9 -Dpplcv_DIR=/home/zzx/data/test_space/cv_ws/ppl.cv/cuda-build/install/lib/cmake/ppl -DTENSORRT_DIR=/home/zzx/TensorRT -DMMDEPLOY_TARGET_DEVICES="cuda;cpu" -DMMDEPLOY_TARGET_BACKENDS=trt -DMMDEPLOY_CODEBASES=all
I made sure the library file was generated ├── libmmdeploy_classifier.so ├── libmmdeploy_core.so ├── libmmdeploy_cpu_device.so ├── libmmdeploy_cpu_transform_impl.so ├── libmmdeploy_cuda_device.so ├── libmmdeploy_cuda_transform_impl.so ├── libmmdeploy_detector.so ├── libmmdeploy_directory_model.so ├── libmmdeploy_graph.so ├── libmmdeploy_mmcls.so ├── libmmdeploy_mmdet.so ├── libmmdeploy_mmedit.so ├── libmmdeploy_mmocr.so ├── libmmdeploy_mmseg.so ├── libmmdeploy_model.so ├── libmmdeploy_net_module.so ├── libmmdeploy_onnxruntime_ops.so ├── libmmdeploy_ort_net.so ├── libmmdeploy_restorer.so ├── libmmdeploy_segmentor.so ├── libmmdeploy_tensorrt_ops.so ├── libmmdeploy_text_detector.so ├── libmmdeploy_text_recognizer.so ├── libmmdeploy_transform_module.so ├── libmmdeploy_transform.so └── libmmdeploy_trt_net.so
MMDeployConfig.cmake have bugs! you can add link_directories 、include_directories、 MMDeploy_LIBS in /path/mmdeploy/build/install/example/CMakelists.txt ,just like these。 thinks!
cmake_minimum_required(VERSION 3.14) project(mmdeploy-example)
include_directories(../include/c) link_directories(/home/zzx/data/test_space/cv_ws/mmdeploy/build/install/lib) find_package(OpenCV REQUIRED)
set(MMDeploy_LIBS mmdeploy_core mmdeploy_cpu_device mmdeploy_cuda_device mmdeploy_graph mmdeploy_directory_model mmdeploy_transform mmdeploy_cpu_transform_impl mmdeploy_cuda_transform_impl mmdeploy_transform_module mmdeploy_trt_net mmdeploy_net_module mmdeploy_mmcls mmdeploy_mmdet mmdeploy_mmseg mmdeploy_mmocr mmdeploy_mmedit mmdeploy_classifier mmdeploy_detector mmdeploy_segmentor mmdeploy_text_detector mmdeploy_text_recognizer mmdeploy_restorer mmdeploy_model)
MMDeployConfig.cmake is generated by cmake/MMDeployConfig.cmake.in
F.Y.I, include_directories
and link_directories
are not recommended in modern cmake.
After cmake .. the variables will be printed, i.e., ${MMDEPLOY_STATIC_MODULES}, ${MMDEPLOY_DYNAMIC_MODULES}, and ${MMDEPLOY_LIBS}
Here is part of my building logs after cmake ..
-- MMDEPLOY_STATIC_MODULES:
-- MMDEPLOY_DYNAMIC_MODULES: mmdeploy_cpu_device;mmdeploy_cuda_device;mmdeploy_graph;mmdeploy_directory_model;mmdeploy_transform;mmdeploy_cpu_transform_impl;mmdeploy_cuda_transform_impl;mmdeploy_transform_module;mmdeploy_trt_net;mmdeploy_net_module;mmdeploy_mmcls;mmdeploy_mmdet;mmdeploy_mmseg;mmdeploy_mmocr;mmdeploy_mmedit
-- MMDEPLOY_LIBS: mmdeploy_core;mmdeploy_archive;mmdeploy_classifier;mmdeploy_detector;mmdeploy_segmentor;mmdeploy_text_detector;mmdeploy_text_recognizer;mmdeploy_restorer;mmdeploy_model
My build steps are:
mkdir -p build
cd build
cmake .. \ -DMMDEPLOY_BUILD_SDK=ON \ -DCMAKE_CXX_COMPILER=g++-9 \ -DOpenCV_DIR=/home/PJLAB/lvhan/Documents/projects/thirdparty/opencv-4.5.3/install/lib/cmake/opencv4 \ -Dpplcv_DIR=/home/PJLAB/lvhan/Documents/projects/thirdparty//ppl.cv/install/lib/cmake/ppl \ -DMMDEPLOY_TARGET_DEVICES="cpu;cuda" \ -DTENSORRT_DIR=/home/PJLAB/lvhan/Documents/projects/thirdparty/nvidia/TensorRT-8.2.1.8 \ -DCUDNN_DIR=/home/PJLAB/lvhan/Documents/projects/thirdparty/nvidia/cudnn-8.2.1 \ -DMMDEPLOY_TARGET_BACKENDS=trt \ -DMMDEPLOY_CODEBASES=all
make -j$(nproc) && make install
2. build MMDeploy examples
```bash
cd install/example
mkdir -p build
cd build
cmake .. -DOpenCV_DIR=/home/PJLAB/lvhan/Documents/projects/thirdparty/opencv-4.5.3/install/lib/cmake/opencv4 \
-DMMDeploy_DIR=/home/PJLAB/lvhan/Documents/projects/open-mmlab/mmdeploy/build/install/lib/cmake/MMDeploy
make -j$(nproc)
The following are the built results:
[ 10%] Building CXX object CMakeFiles/image_segmentation.dir/image_segmentation.cpp.o
[ 20%] Building CXX object CMakeFiles/ocr.dir/ocr.cpp.o
[ 30%] Building CXX object CMakeFiles/image_classification.dir/image_classification.cpp.o
[ 40%] Building CXX object CMakeFiles/image_restorer.dir/image_restorer.cpp.o
[ 50%] Building CXX object CMakeFiles/object_detection.dir/object_detection.cpp.o
[ 60%] Linking CXX executable image_classification
[ 70%] Linking CXX executable ocr
[ 80%] Linking CXX executable image_restorer
[ 90%] Linking CXX executable image_segmentation
[100%] Linking CXX executable object_detection
[100%] Built target image_classification
[100%] Built target ocr
[100%] Built target image_segmentation
[100%] Built target image_restorer
[100%] Built target object_detection
In build/install/ib
, the file structure is:
.
├── cmake
│ └── MMDeploy
│ ├── MMDeployConfig.cmake
│ ├── MMDeployConfigVersion.cmake
│ ├── MMDeployTargets.cmake
│ └── MMDeployTargets-release.cmake
├── libmmdeploy_classifier.so
├── libmmdeploy_core.so
├── libmmdeploy_cpu_device.so
├── libmmdeploy_cpu_transform_impl.so
├── libmmdeploy_cuda_device.so
├── libmmdeploy_cuda_transform_impl.so
├── libmmdeploy_detector.so
├── libmmdeploy_directory_model.so
├── libmmdeploy_graph.so
├── libmmdeploy_mmcls.so
├── libmmdeploy_mmdet.so
├── libmmdeploy_mmedit.so
├── libmmdeploy_mmocr.so
├── libmmdeploy_mmseg.so
├── libmmdeploy_model.so
├── libmmdeploy_net_module.so
├── libmmdeploy_restorer.so
├── libmmdeploy_segmentor.so
├── libmmdeploy_tensorrt_ops.so
├── libmmdeploy_text_detector.so
├── libmmdeploy_text_recognizer.so
├── libmmdeploy_transform_module.so
├── libmmdeploy_transform.so
└── libmmdeploy_trt_net.so
问题一.编译SDK的c example demo的时候,发现找不到动态库。指定了config.cmake的路径。 我在cmakelist里面打印 message(STATUS "need ${MMDeploy_LIBS}") 然后cmke .. ${MMDEPLOY_DIR}/build/install/lib/cmake/MMDeploy .. 显示 -- need -Wl,--no-as-needed;-Wl,--as-needed;-Wl,--whole-archive;-Wl,--no-whole-archive 然后对照MMDeployConfig.cmake中 set(MMDeploy_LIBS ${MMDEPLOY_LIBS} -Wl,--no-as-needed ${MMDEPLOY_DYNAMIC_MODULES} -Wl,--as-needed -Wl,--whole-archive ${MMDEPLOY_STATIC_MODULES} -Wl,--no-whole-archive)
其中是不是MMDEPLOY_DYNAMIC_MODULES MMDEPLOY_STATIC_MODULES 变量没有赋值的。