MNN icon indicating copy to clipboard operation
MNN copied to clipboard

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

Open CloudGuardian opened this issue 1 year ago • 6 comments

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

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耗时问题吗?谢谢

CloudGuardian avatar Apr 29 '24 02:04 CloudGuardian

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

jxt1234 avatar Apr 29 '24 02:04 jxt1234

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

都是30多秒,没有变化😂

CloudGuardian avatar Apr 29 '24 02:04 CloudGuardian

cache 文件是否读取成功了?

jxt1234 avatar May 08 '24 06:05 jxt1234

cache 文件是否读取成功了?

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

第二次的时候就没了 image

CloudGuardian avatar May 10 '24 09:05 CloudGuardian

cache 文件是否读取成功了?

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

CloudGuardian avatar May 14 '24 08:05 CloudGuardian

cache 文件是否读取成功了?

我试了一下,如果是小模型(500k)的话.cache是有收益的,但是原本的模型大约8M,基本没有收益

CloudGuardian avatar May 28 '24 09:05 CloudGuardian

Marking as stale. No activity in 60 days.

github-actions[bot] avatar Jul 27 '24 09:07 github-actions[bot]