From 59449cc128c296783259ac67dc971573e185cbd9 Mon Sep 17 00:00:00 2001 From: nino Date: Sun, 8 Oct 2023 15:40:56 +0800 Subject: [PATCH] CodeCamp2023-670 (#2476) * Update the document of building mmdeploy with ncnn backend on Windows platform * fix a bug * fix lint error * fix lint error --- docs/en/01-how-to-build/windows.md | 51 ++++++++++++++++++++++++-- docs/zh_cn/01-how-to-build/windows.md | 52 +++++++++++++++++++++++++-- 2 files changed, 99 insertions(+), 4 deletions(-) diff --git a/docs/en/01-how-to-build/windows.md b/docs/en/01-how-to-build/windows.md index 1c27bdc264..5e37b8c4a8 100644 --- a/docs/en/01-how-to-build/windows.md +++ b/docs/en/01-how-to-build/windows.md @@ -186,7 +186,23 @@ $env:path = "$env:CUDNN_DIR\bin;" + $env:path ncnn ncnn - TODO + 1. Download protobuf-3.11.2
+ 2. Compile protobuf +
cd <protobuf-dir>
+mkdir build
+cd build
+cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -Dbuild_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake
+cmake --build . --config Release -j 2
+cmake --build . --config Release --target install
+ 2. Download ncnn +
git clone --recursive https://github.com/Tencent/ncnn.git
+cd <ncnn-dir>
+mkdir -p ncnn_build
+cd ncnn_build
+cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -Dprotobuf_DIR=/build/install/cmake -DNCNN_VULKAN=OFF ..
+cmake --build . --config Release -j 2
+cmake --build . --config Release --target install
+
@@ -224,7 +240,18 @@ cmake --install . --config Release - **ncnn** Custom Ops - TODO +```powershell +mkdir build -ErrorAction SilentlyContinue +cd build +cmake .. -G "Visual Studio 16 2019" -A x64 -T v142 +-DMMDEPLOY_TARGET_BACKENDS="ncnn" \ +-Dncnn_DIR="/ncnn_build/install/lib/cmake/ncnn" +-Dprotobuf_DIR="/build/install/cmake" +-DProtobuf_LIBRARIES="/build\install\lib" +-DProtobuf_INCLUDE_DIR="/build\install\include\" +cmake --build . --config Release -- /m +cmake --install . --config Release +``` Please check [cmake build option](cmake_option.md). @@ -284,6 +311,26 @@ You can also activate other engines after the model. cmake --install . --config Release ``` +- cpu + ncnn + + ```PowerShell + cd $env:MMDEPLOY_DIR + mkdir build + cd build + cmake .. -G "Visual Studio 16 2019" -A x64 -T v142 ` + -DMMDEPLOY_BUILD_SDK=ON ` + -DMMDEPLOY_BUILD_EXAMPLES=ON ` + -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON ` + -DMMDEPLOY_TARGET_DEVICES="cpu" ` + -DMMDEPLOY_TARGET_BACKENDS="ncnn" ` + -Dncnn_DIR="/ncnn_build/install/lib/cmake/ncnn" + -Dprotobuf_DIR="/build/install/cmake" + -DProtobuf_LIBRARIES="/build\install\lib" + -DProtobuf_INCLUDE_DIR="/build\install\include\" + cmake --build . --config Release -- /m + cmake --install . --config Release + ``` + ### Note 1. Release / Debug libraries can not be mixed. If MMDeploy is built with Release mode, all its dependent thirdparty libraries have to be built in Release mode too and vice versa. diff --git a/docs/zh_cn/01-how-to-build/windows.md b/docs/zh_cn/01-how-to-build/windows.md index ef3645d6b9..1680077cb4 100644 --- a/docs/zh_cn/01-how-to-build/windows.md +++ b/docs/zh_cn/01-how-to-build/windows.md @@ -180,7 +180,25 @@ $env:path = "$env:CUDNN_DIR\bin;" + $env:path ncnn ncnn - TODO + + 1. 下载 protobuf-3.11.2
+ 2. 编译protobuf +
cd <protobuf-dir>
+mkdir build
+cd build
+cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -Dbuild_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake
+cmake --build . --config Release -j 2
+cmake --build . --config Release --target install
+ 2. 下载ncnn +
git clone --recursive https://github.com/Tencent/ncnn.git
+cd <ncnn-dir>
+mkdir -p ncnn_build
+cd ncnn_build
+cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -Dprotobuf_DIR=/build/install/cmake -DNCNN_VULKAN=OFF ..
+cmake --build . --config Release -j 2
+cmake --build . --config Release --target install
+
+ @@ -218,7 +236,18 @@ cmake --install . --config Release - **ncnn** 自定义算子 - TODO +```powershell +mkdir build -ErrorAction SilentlyContinue +cd build +cmake .. -G "Visual Studio 16 2019" -A x64 -T v142 +-DMMDEPLOY_TARGET_BACKENDS="ncnn" \ +-Dncnn_DIR="/ncnn_build/install/lib/cmake/ncnn" +-Dprotobuf_DIR="/build/install/cmake" +-DProtobuf_LIBRARIES="/build\install\lib" +-DProtobuf_INCLUDE_DIR="/build\install\include\" +cmake --build . --config Release -- /m +cmake --install . --config Release +``` 参考 [cmake 选项说明](cmake_option.md) @@ -271,7 +300,26 @@ pip install -e . -Dpplcv_DIR="$env:PPLCV_DIR/pplcv-build/install/lib/cmake/ppl" ` -DTENSORRT_DIR="$env:TENSORRT_DIR" ` -DCUDNN_DIR="$env:CUDNN_DIR" + cmake --build . --config Release -- /m + cmake --install . --config Release + ``` + +- cpu + ncnn + ```PowerShell + cd $env:MMDEPLOY_DIR + mkdir build + cd build + cmake .. -G "Visual Studio 16 2019" -A x64 -T v142 ` + -DMMDEPLOY_BUILD_SDK=ON ` + -DMMDEPLOY_BUILD_EXAMPLES=ON ` + -DMMDEPLOY_BUILD_SDK_PYTHON_API=ON ` + -DMMDEPLOY_TARGET_DEVICES="cpu" ` + -DMMDEPLOY_TARGET_BACKENDS="ncnn" ` + -Dncnn_DIR="/ncnn_build/install/lib/cmake/ncnn" + -Dprotobuf_DIR="/build/install/cmake" + -DProtobuf_LIBRARIES="/build\install\lib" + -DProtobuf_INCLUDE_DIR="/build\install\include\" cmake --build . --config Release -- /m cmake --install . --config Release ```