MNN icon indicating copy to clipboard operation
MNN copied to clipboard

MNN 在 iOS平台上编译mnn_2.8.0_ios_llm.zip release版本的方法

Open xingjinglu opened this issue 10 months ago • 3 comments

现在是在mac上,通过 project/ios/下的项目直接打开进行编译。现在的问题: 1)编译出来的MNN库大小是8.1MB,比 2.8.0 release的版本的要大; 2)执行llm推理时,会存在占用内存过大被杀死的问题;

但是使用下面版本的MNN库,就可以正常图例qwen1.8b-int8模型,能否提供一下编译mnn_2.8.0_ios_llm.zip 的方法。 https://github.com/alibaba/MNN/releases/download/2.8.0/mnn_2.8.0_ios_llm.zip

xingjinglu avatar Apr 25 '24 09:04 xingjinglu

解决了,修改一下 project/ios/ xcode项目的配置即可,具体如下:

1)# 预处理编译选项 Preprocessor Macros $(inherited) MNN_CODEGEN_REGISTER=1 MNN_METAL_ENABLED=1 ENABLE_ARMV82=1 MNN_COREML_ENABLED=1 USE_LZ4_FLAG=1 MNN_USE_SPARSE_COMPUTE=1 MNN_LOW_MEMORY=1

2) 添加下面文件 source/backend/arm82/asm/arm64/low_memory/ source/backend/cpu/arm/arm64/low_memory

3)针对下面的上面的文件设置编译选项:-march=armv8.2-a+fp16

具体可以参考 https://github.com/xingjinglu/MNN/tree/memory_compress/project/ios/MNN.xcodeproj

xingjinglu avatar Apr 28 '24 02:04 xingjinglu

一般参考 package_scripts/ios/buildiOS.sh 用脚本编译,额外加上编译参数 -DMNN_LOW_MEMORY=ON

jxt1234 avatar Apr 29 '24 02:04 jxt1234

Marking as stale. No activity in 60 days.

github-actions[bot] avatar Jun 28 '24 09:06 github-actions[bot]