Skip to content

Commit 59449cc

Browse files
author
nino
authored
CodeCamp2023-670 (#2476)
* Update the document of building mmdeploy with ncnn backend on Windows platform * fix a bug * fix lint error * fix lint error
1 parent 4cf0f92 commit 59449cc

File tree

2 files changed

+99
-4
lines changed

2 files changed

+99
-4
lines changed

docs/en/01-how-to-build/windows.md

Lines changed: 49 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,23 @@ $env:path = "$env:CUDNN_DIR\bin;" + $env:path
186186
<tr>
187187
<td>ncnn </td>
188188
<td>ncnn </td>
189-
<td>TODO </td>
189+
<td>1. Download <a href="https://github.com/google/protobuf/archive/v3.11.2.zip">protobuf-3.11.2</a><br>
190+
2. Compile protobuf
191+
<pre><code>cd &ltprotobuf-dir>
192+
mkdir build
193+
cd build
194+
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -Dbuild_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake
195+
cmake --build . --config Release -j 2
196+
cmake --build . --config Release --target install</code></pre>
197+
2. Download ncnn
198+
<pre><code>git clone --recursive https://github.com/Tencent/ncnn.git
199+
cd &ltncnn-dir>
200+
mkdir -p ncnn_build
201+
cd ncnn_build
202+
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -Dprotobuf_DIR=<protobuf-dir>/build/install/cmake -DNCNN_VULKAN=OFF ..
203+
cmake --build . --config Release -j 2
204+
cmake --build . --config Release --target install
205+
</code></pre> </td>
190206
</tr>
191207
</tbody>
192208
</table>
@@ -224,7 +240,18 @@ cmake --install . --config Release
224240

225241
- **ncnn** Custom Ops
226242

227-
TODO
243+
```powershell
244+
mkdir build -ErrorAction SilentlyContinue
245+
cd build
246+
cmake .. -G "Visual Studio 16 2019" -A x64 -T v142
247+
-DMMDEPLOY_TARGET_BACKENDS="ncnn" \
248+
-Dncnn_DIR="<ncnn-dir>/ncnn_build/install/lib/cmake/ncnn"
249+
-Dprotobuf_DIR="<protobuf-dir>/build/install/cmake"
250+
-DProtobuf_LIBRARIES="<protobuf-dir>/build\install\lib"
251+
-DProtobuf_INCLUDE_DIR="<protobuf-dir>/build\install\include\"
252+
cmake --build . --config Release -- /m
253+
cmake --install . --config Release
254+
```
228255

229256
Please check [cmake build option](cmake_option.md).
230257

@@ -284,6 +311,26 @@ You can also activate other engines after the model.
284311
cmake --install . --config Release
285312
```
286313

314+
- cpu + ncnn
315+
316+
```PowerShell
317+
cd $env:MMDEPLOY_DIR
318+
mkdir build
319+
cd build
320+
cmake .. -G "Visual Studio 16 2019" -A x64 -T v142 `
321+
-DMMDEPLOY_BUILD_SDK=ON `
322+
-DMMDEPLOY_BUILD_EXAMPLES=ON `
323+
-DMMDEPLOY_BUILD_SDK_PYTHON_API=ON `
324+
-DMMDEPLOY_TARGET_DEVICES="cpu" `
325+
-DMMDEPLOY_TARGET_BACKENDS="ncnn" `
326+
-Dncnn_DIR="<ncnn-dir>/ncnn_build/install/lib/cmake/ncnn"
327+
-Dprotobuf_DIR="<protobuf-dir>/build/install/cmake"
328+
-DProtobuf_LIBRARIES="<protobuf-dir>/build\install\lib"
329+
-DProtobuf_INCLUDE_DIR="<protobuf-dir>/build\install\include\"
330+
cmake --build . --config Release -- /m
331+
cmake --install . --config Release
332+
```
333+
287334
### Note
288335

289336
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.

docs/zh_cn/01-how-to-build/windows.md

Lines changed: 50 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,25 @@ $env:path = "$env:CUDNN_DIR\bin;" + $env:path
180180
<tr>
181181
<td>ncnn </td>
182182
<td>ncnn </td>
183-
<td>TODO </td>
183+
<td>
184+
1. 下载 <a href="https://github.com/google/protobuf/archive/v3.11.2.zip">protobuf-3.11.2</a><br>
185+
2. 编译protobuf
186+
<pre><code>cd &ltprotobuf-dir>
187+
mkdir build
188+
cd build
189+
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -Dbuild_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake
190+
cmake --build . --config Release -j 2
191+
cmake --build . --config Release --target install</code></pre>
192+
2. 下载ncnn
193+
<pre><code>git clone --recursive https://github.com/Tencent/ncnn.git
194+
cd &ltncnn-dir>
195+
mkdir -p ncnn_build
196+
cd ncnn_build
197+
cmake -G "Visual Studio 16 2019" -A x64 -DCMAKE_INSTALL_PREFIX=%cd%/install -Dprotobuf_DIR=<protobuf-dir>/build/install/cmake -DNCNN_VULKAN=OFF ..
198+
cmake --build . --config Release -j 2
199+
cmake --build . --config Release --target install
200+
</code></pre>
201+
</td>
184202
</tr>
185203
</tbody>
186204
</table>
@@ -218,7 +236,18 @@ cmake --install . --config Release
218236

219237
- **ncnn** 自定义算子
220238

221-
TODO
239+
```powershell
240+
mkdir build -ErrorAction SilentlyContinue
241+
cd build
242+
cmake .. -G "Visual Studio 16 2019" -A x64 -T v142
243+
-DMMDEPLOY_TARGET_BACKENDS="ncnn" \
244+
-Dncnn_DIR="<ncnn-dir>/ncnn_build/install/lib/cmake/ncnn"
245+
-Dprotobuf_DIR="<protobuf-dir>/build/install/cmake"
246+
-DProtobuf_LIBRARIES="<protobuf-dir>/build\install\lib"
247+
-DProtobuf_INCLUDE_DIR="<protobuf-dir>/build\install\include\"
248+
cmake --build . --config Release -- /m
249+
cmake --install . --config Release
250+
```
222251

223252
参考 [cmake 选项说明](cmake_option.md)
224253

@@ -271,7 +300,26 @@ pip install -e .
271300
-Dpplcv_DIR="$env:PPLCV_DIR/pplcv-build/install/lib/cmake/ppl" `
272301
-DTENSORRT_DIR="$env:TENSORRT_DIR" `
273302
-DCUDNN_DIR="$env:CUDNN_DIR"
303+
cmake --build . --config Release -- /m
304+
cmake --install . --config Release
305+
```
306+
307+
- cpu + ncnn
274308

309+
```PowerShell
310+
cd $env:MMDEPLOY_DIR
311+
mkdir build
312+
cd build
313+
cmake .. -G "Visual Studio 16 2019" -A x64 -T v142 `
314+
-DMMDEPLOY_BUILD_SDK=ON `
315+
-DMMDEPLOY_BUILD_EXAMPLES=ON `
316+
-DMMDEPLOY_BUILD_SDK_PYTHON_API=ON `
317+
-DMMDEPLOY_TARGET_DEVICES="cpu" `
318+
-DMMDEPLOY_TARGET_BACKENDS="ncnn" `
319+
-Dncnn_DIR="<ncnn-dir>/ncnn_build/install/lib/cmake/ncnn"
320+
-Dprotobuf_DIR="<protobuf-dir>/build/install/cmake"
321+
-DProtobuf_LIBRARIES="<protobuf-dir>/build\install\lib"
322+
-DProtobuf_INCLUDE_DIR="<protobuf-dir>/build\install\include\"
275323
cmake --build . --config Release -- /m
276324
cmake --install . --config Release
277325
```

0 commit comments

Comments
 (0)