目录
第五步:Build ncnn library (replace with a proper path)
ncnn在windows下编译
第一步:安装VS2017
因为我的电脑本来装了VS2019,所以直接用VS2019试一下~
Download and Install Visual Studio Community 2017 from Visual Studio 2019 Community Edition – Download Latest Free Version
第二步:下载ncnn和protobuf源码
Download protobuf-3.4.0 from https://github.com/google/protobuf/archive/v3.4.0.zip
Download ncnn from github: https://github.com/Tencent/ncnn
$ git clone https://github.com/Tencent/ncnn.git
$ cd ncnn
$ git submodule update --init
第三步:Start the command prompt
官网给的是用x64 Native Tools Command Prompt for VS 2017编译,我用的是x64 Native Tools Command Prompt for VS 2019也可!这里注意使用x64进行编译不要用x86 Native Tools Command Prompt for VS 2019!!!
Start the command prompt: Start → Programs → Visual Studio 2019 → Visual Studio Tools → x64 Native Tools Command Prompt for VS 2019如下图:
第三步:build protobuf library
cd <protobuf-root-dir>
mkdir build
cd build
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%cd%/install -Dprotobuf_BUILD_TESTS=OFF -Dprotobuf_MSVC_STATIC_RUNTIME=OFF ../cmake
nmake
nmake install
第四步:安装Vulkan
Download and install Vulkan SDK from LunarXchange
正常下载安装到一个自己感觉舒服的位置上
第五步:Build ncnn library (replace with a proper path)
build ncnn 注意替换命令中的protobuf的路径为自己的protobuf的路径
cd <ncnn-root-dir>
mkdir -p build
cd build
cmake -G"NMake Makefiles" -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=%cd%/install -DProtobuf_INCLUDE_DIR=<protobuf-root-dir>/build/install/include -DProtobuf_LIBRARIES=<protobuf-root-dir>/build/install/lib/libprotobuf.lib -DProtobuf_PROTOC_EXECUTABLE=<protobuf-root-dir>/build/install/bin/protoc.exe -DNCNN_VULKAN=ON ..
nmake
nmake install
Note: To speed up compilation process on multi core machines, configuring cmake
to use jom
or ninja
using -G
flag is recommended.
至此ncnn就编译完成了,待用
接下来去转模型pt2onnx2ncnn,转到下一篇“yolov5s-v3.1 ncnn 部署(二)”