前言
注意:本教程只是对官方编译的一个补全和纠正
官方教程:https://github.com/Tencent/ncnn/wiki/how-to-build#build-for-windows-x64-using-visual-studio-community-2017
CMAKE编译NCNN x64
下载protobuf-3.11.2:https://github.com/google/protobuf/archive/v3.11.2.zip
编译protobuf:
1 2 3 4 5 6 7 8
| cd <protobuf根目录> mkdir protobuf_build cd protobuf_build
cmake -A x64 -DCMAKE_INSTALL_PREFIX=install -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=ON ../cmake cmake --build . --config Release -j 2 cmake --build . --config Release --target install
|
下载Vulkan库,让NCNN使用GPU去推理: https://vulkan.lunarg.com/sdk/home
编译NCNN:
1 2 3 4 5 6 7 8
| cd <ncnn根目录> mkdir -p protobuf_build cd protobuf_build
cmake -A x64 -DCMAKE_INSTALL_PREFIX=install -Dprotobuf_DIR=<protobuf根目录>/protobuf_build/install/cmake -DNCNN_VULKAN=ON -DNCNN_BUILD_WITH_STATIC_CRT=ON .. cmake --build . --config Release -j 2 cmake --build . --config Release --target install
|
写在最后
本地编译的ncnnoptimize无法优化模型,建议下载官方编译好的进行替换,如果你知道怎么解决欢迎评论。