[2019-12-31]
今天看到更新了0.2.16,尝试了下,顺畅多了, MNNConvert.exe 也能顺利运行。
更简单的流程:
1、下载解压
2、vs2015x64命令符下,转MNN-0.2.1.6路径
3、
powershell -ExecutionPolicy bypass ./schema/generate.ps1
4、
mkdir vs15x64 && cd vs15x64 cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DMNN_BUILD_CONVERTER=ON -DMNN_BUILD_SHARED_LIBS=OFF ..
5、用vs2015打开.sln下编译
bug(很容易修改)
- vs2015支持不够,需要修改一些类型转换
- MNNConvert.exe 缺少必要库的连接
-MNNTrain改静态库
看到train模块,希望mnn走得远些
用过腾讯的ncnn,编译起来很友好;但是对3d操作算子支持不够;导致新出现的模型无法使用。
看到阿里开发的mnn (V 0.2.1.5),来尝尝鲜,结果断续折腾了2天,以此记之。
非常感谢:
https://uzshare.com/view/810473
https://www.yuque.com/mnn/cn/build_windows
里面详细介绍了一些配置操作。
1、设置
2、将powershell ./schema/generate.ps1换成python ./schema/generate.py
如果要编译x64,将
os.system('cmake -DCMAKE_BUILD_TYPE=Release ..')
修改成
os.system('cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release ..')
这个步骤也可以直接去
https://github.com/google/flatbuffers/releases
下flatc.exe, 在..\MNN-master\3rd_party\flatbuffers\tmp\flatc.exe
3、cmake x64 only mnn.lib/mnn.dll
mkdir vs15x64 && cd vs15x64 cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release .. cd.. cmake --build vs15x64 --config Release
正常会有
error C2280: 'std::unique_ptr<MNN::Pipeline,std::default_delete<_Ty>> &std::unique_ptr<_Ty,std::default_delete<_Ty>>::operator =(const std::unique_ptr<_Ty,std::default_delete<_Ty>> &)': attempting to reference a deleted function
解法:https://github.com/Hconk/MNN/commit/819a666135a420f680675d503fabfa14028e13d2
//Session.hpp
private:
std::map<MNNForwardType, std::unique_ptr<Backend>> mBackends;
std::vector<std::unique_ptr<Pipeline>> mPipelines;
std::vector<std::pair<int, std::shared_ptr<Tensor>>> mTensors;
std::map<std::string, Tensor*> mInputs;
std::map<std::string, Tensor*> mOutputs;
bool mNeedResize = false;
bool mValid = true;
Backend* mFirstBackend = nullptr;
Session(const Session&) = delete;
Session(const Session&&) = delete;
Session& operator=(const Session&) = delete;
Session& operator=(const Session&&) = delete;
这样基本就可以获取MNN.lib 与MNN.dll了。
4、编译Conver Tool 【这个折腾我最久,好像爆粗口】
参考 https://www.yuque.com/mnn/cn/cvrt_windows
不要在tool\s\converter在使用cmake, 在MNN-master下cmake,
cmake -G "Visual Studio 14 2015 Win64" -DCMAKE_BUILD_TYPE=Release -DMNN_BUILD_CONVERTER=ON -DMNN_BUILD_SHARED_LIBS=OFF ..
Q1、配置 protobuf
Win7 下,添加环境变量 protoc.exe 所在的路径,然后cmd下运行protoc.exe
这样基本就可以编译过了
**** 生成的 MNNConvert.exe 无法执行 ***