alibaba / MNN

MNN is a blazing fast, lightweight deep learning framework, battle-tested by business-critical use cases in Alibaba
http://www.mnn.zone/
8.34k stars 1.62k forks source link

Android平台下OpenCL使用setCacheFile(),模型的初始化时间未得到优化 #2852

Open CloudGuardian opened 2 weeks ago

CloudGuardian commented 2 weeks ago

平台(如果交叉编译请再附上交叉编译目标平台):

Platform(Include target platform as well if cross-compiling):

Android平台GPU:Arm Mali-G57

Github版本:

Github Version:

2-8-1

代码如下:

std::shared_ptr<MNN::Interpreter> mnnNet;
mnnNet = std::shared_ptr<MNN::Interpreter>(MNN::Interpreter::createFromFile(model_name.c_str()));
mnnNet->setCacheFile(".tempcache");

ScheduleConfig netConfig;
netConfig.type = MNN_FORWARD_OPENCL;
netConfig.mode = MNN_GPU_TUNING_NORMAL | MNN_GPU_MEMORY_BUFFER;
netConfig.numThread = 1;  

BackendConfig backendConfig;
backendConfig.precision = BackendConfig::Precision_High;
backendConfig.power = BackendConfig::Power_Normal;
netConfig.backendConfig = &backendConfig;
MNN::Session* session = mnnNet->createSession(netConfig);

/*
推理
*/

mnnNet->updateCacheFile(session);

Log:

The device support i8sdot:1, support fp16:1, support i8mm: 0
Update cache to .tempcache, from size:329124 -> size:347844

主要是createSession的耗时过长,需要30多秒,使用setCacheFile()后耗时仍是这么多; 还有办法进一步优化createSession耗时问题吗?谢谢

jxt1234 commented 2 weeks ago

setCacheFile 是加快第二次 createSession 的,前后两次 createSession 的耗时对比是多少?

CloudGuardian commented 2 weeks ago

setCacheFile 是加快第二次 createSession 的,前后两次 createSession 的耗时对比是多少?

都是30多秒,没有变化😂

jxt1234 commented 1 week ago

cache 文件是否读取成功了?

CloudGuardian commented 5 days ago

cache 文件是否读取成功了?

第一次的时候会报一个err log image

第二次的时候就没了 image

CloudGuardian commented 1 day ago

cache 文件是否读取成功了?

第二次读取的时候还是使用setCacheFile()吗?