MNN icon indicating copy to clipboard operation
MNN copied to clipboard

Can MNN be compiled in Apple M1 max (arm64 proccesor)?

Open LeoCloser opened this issue 1 year ago • 1 comments

I'm working to build MNN 2.8.0 version on Mac Studio Apple M1 max but I'm getting errors while i try to run my program. In linux i didn't have any issues but when i changed to mac m1 i got an final error ld: symbol(s) not found for architecture arm64

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

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

Mac Studio: Apple M1 Max macOS: 13.5 Beta (22G5059d)

Using Qt 6.3.1 Based on Qt 5.15.2 (Clang 11.0 (Apple), 64 bit)

Github版本:

Github Version:

直接下载ZIP包请提供下载日期以及压缩包注释里的git版本(可通过7z l zip包路径命令并在输出信息中搜索Comment 获得,形如Comment = bc80b11110cd440aacdabbf59658d630527a7f2b)。 git clone请提供 git commit 第一行的commit id

Provide date (or better yet, git revision from the comment section of the zip. Obtainable using 7z l PATH/TO/ZIP and search for Comment in the output) if downloading source as zip,otherwise provide the first commit id from the output of git commit

编译方式:

Compiling Method


Compilation results in MNN (seems correct)

DOING cmake -G "Unix Makefiles" -DMNN_FORBID_MULTI_THREAD=OFF -DMNN_USE_THREAD_POOL=ON -DMNN_SUPPORT_TFLITE_QUAN=ON -DMNN_OPENCL=ON -DMNN_BUILD_SHARED_LIBS=0 -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/Users/USER/Desktop/REPOLIB/USER/MNN_Library/MNN-2.8.0/build /Users/USER/Desktop/repos/REPOLIB/MNN_Library/MNN-2.8.0 -- Use Threadpool, forbid openmp -- >>>>>>>>>>>>> -- MNN BUILD INFO: -- System: Darwin -- Processor: arm64 -- Version: 2.8.0 -- Metal: OFF -- OpenCL: ON -- OpenGL: OFF -- Vulkan: OFF -- ARM82: OFF -- oneDNN: OFF -- TensorRT: OFF -- CoreML: OFF -- NNAPI: OFF -- CUDA: OFF -- OpenMP: OFF -- BF16: OFF -- ThreadPool: ON -- Hidden: TRUE -- Build Path: /Users/srt/Desktop/repos/leorepo/MNN_Library/MNN-2.8.0 -- CUDA PROFILE: OFF -- WIN_USE_ASM: -- Enabling AArch64 Assemblies -- Configuring done -- Generating done -- Build files have been written to: /Users/srt/Desktop/repos/leorepo/MNN_Library/MNN-2.8.0 Password: Consolidate compiler generated dependencies of target MNNCore [ 0%] Building CXX object CMakeFiles/MNNCore.dir/source/core/AutoTime.cpp.o [ 0%] Building CXX object CMakeFiles/MNNCore.dir/source/core/Backend.cpp.o [ 1%] Building CXX object CMakeFiles/MNNCore.dir/source/core/BackendRegister.cpp.o [ 1%] Building CXX object CMakeFiles/MNNCore.dir/source/core/BufferAllocator.cpp.o [ 1%] Building CXX object CMakeFiles/MNNCore.dir/source/core/ConvolutionCommon.cpp.o [ 1%] Building CXX object CMakeFiles/MNNCore.dir/source/core/Execution.cpp.o

[ 91%] Built target MNN_CL Consolidate compiler generated dependencies of target MNN [ 91%] Building CXX object CMakeFiles/MNN.dir/cmake/dummy.cpp.o [ 91%] Linking CXX static library libMNN.a [ 91%] Built target MNN Consolidate compiler generated dependencies of target GetMNNInfo [ 91%] Building CXX object CMakeFiles/GetMNNInfo.dir/tools/cpp/GetMNNInfo.cpp.o [ 91%] Linking CXX executable GetMNNInfo ld: warning: option -noall_load is obsolete and being ignored [ 91%] Built target GetMNNInfo Consolidate compiler generated dependencies of target ModuleBasic.out [ 91%] Building CXX object CMakeFiles/ModuleBasic.out.dir/tools/cpp/ModuleBasic.cpp.o [ 92%] Linking CXX executable ModuleBasic.out ld: warning: option -noall_load is obsolete and being ignored [ 92%] Built target ModuleBasic.out Consolidate compiler generated dependencies of target SequenceModuleTest.out [ 92%] Building CXX object CMakeFiles/SequenceModuleTest.out.dir/tools/cpp/SequenceModuleTest.cpp.o [ 92%] Linking CXX executable SequenceModuleTest.out ld: warning: option -noall_load is obsolete and being ignored [ 92%] Built target SequenceModuleTest.out Consolidate compiler generated dependencies of target mergeInplaceForCPU [ 93%] Building CXX object CMakeFiles/mergeInplaceForCPU.dir/tools/cpp/mergeInplaceForCPU.cpp.o [ 93%] Linking CXX executable mergeInplaceForCPU ld: warning: option -noall_load is obsolete and being ignored [ 93%] Built target mergeInplaceForCPU Consolidate compiler generated dependencies of target MNNV2Basic.out [ 93%] Building CXX object CMakeFiles/MNNV2Basic.out.dir/tools/cpp/MNNV2Basic.cpp.o [ 94%] Linking CXX executable MNNV2Basic.out ld: warning: option -noall_load is obsolete and being ignored [ 94%] Built target MNNV2Basic.out Consolidate compiler generated dependencies of target mobilenetTest.out [ 94%] Building CXX object CMakeFiles/mobilenetTest.out.dir/tools/cpp/mobilenetTest.cpp.o [ 94%] Linking CXX executable mobilenetTest.out ld: warning: option -noall_load is obsolete and being ignored [ 94%] Built target mobilenetTest.out Consolidate compiler generated dependencies of target backendTest.out [ 94%] Building CXX object CMakeFiles/backendTest.out.dir/tools/cpp/backendTest.cpp.o [ 94%] Linking CXX executable backendTest.out ld: warning: option -noall_load is obsolete and being ignored [ 94%] Built target backendTest.out Consolidate compiler generated dependencies of target testModel.out [ 94%] Building CXX object CMakeFiles/testModel.out.dir/tools/cpp/testModel.cpp.o [ 95%] Linking CXX executable testModel.out ld: warning: option -noall_load is obsolete and being ignored [ 95%] Built target testModel.out Consolidate compiler generated dependencies of target testModel_expr.out [ 95%] Building CXX object CMakeFiles/testModel_expr.out.dir/tools/cpp/testModel_expr.cpp.o [ 96%] Linking CXX executable testModel_expr.out ld: warning: option -noall_load is obsolete and being ignored [ 96%] Built target testModel_expr.out Consolidate compiler generated dependencies of target testModelWithDescribe.out [ 96%] Building CXX object CMakeFiles/testModelWithDescribe.out.dir/tools/cpp/testModelWithDescribe.cpp.o [ 96%] Linking CXX executable testModelWithDescribe.out ld: warning: option -noall_load is obsolete and being ignored [ 96%] Built target testModelWithDescribe.out Consolidate compiler generated dependencies of target getPerformance.out [ 96%] Building CXX object CMakeFiles/getPerformance.out.dir/tools/cpp/getPerformance.cpp.o [ 96%] Linking CXX executable getPerformance.out ld: warning: option -noall_load is obsolete and being ignored [ 96%] Built target getPerformance.out Consolidate compiler generated dependencies of target checkInvalidValue.out [ 97%] Building CXX object CMakeFiles/checkInvalidValue.out.dir/tools/cpp/checkInvalidValue.cpp.o [ 97%] Linking CXX executable checkInvalidValue.out ld: warning: option -noall_load is obsolete and being ignored [ 97%] Built target checkInvalidValue.out Consolidate compiler generated dependencies of target timeProfile.out [ 97%] Building CXX object CMakeFiles/timeProfile.out.dir/tools/cpp/timeProfile.cpp.o [ 98%] Building CXX object CMakeFiles/timeProfile.out.dir/tools/cpp/revertMNNModel.cpp.o [ 98%] Building CXX object CMakeFiles/timeProfile.out.dir/tools/cpp/Profiler.cpp.o [ 98%] Linking CXX executable timeProfile.out ld: warning: option -noall_load is obsolete and being ignored [ 98%] Built target timeProfile.out Consolidate compiler generated dependencies of target testTrain.out [ 98%] Building CXX object CMakeFiles/testTrain.out.dir/tools/cpp/testTrain.cpp.o [ 98%] Linking CXX executable testTrain.out ld: warning: option -noall_load is obsolete and being ignored [ 98%] Built target testTrain.out Consolidate compiler generated dependencies of target checkDir.out [ 99%] Building CXX object CMakeFiles/checkDir.out.dir/tools/cpp/checkDir.cpp.o [ 99%] Linking CXX executable checkDir.out [ 99%] Built target checkDir.out Consolidate compiler generated dependencies of target checkFile.out [ 99%] Building CXX object CMakeFiles/checkFile.out.dir/tools/cpp/checkFile.cpp.o [ 99%] Linking CXX executable checkFile.out [ 99%] Built target checkFile.out Consolidate compiler generated dependencies of target winogradExample.out [ 99%] Building CXX object CMakeFiles/winogradExample.out.dir/tools/cpp/winogradExample.cpp.o [100%] Linking CXX executable winogradExample.out ld: warning: option -noall_load is obsolete and being ignored [100%] Built target winogradExample.out


# 编译日志:
# Build Log:

粘贴在这里
Paste log here or pastebin

I got this error on qt log.
  "MNN::Interpreter::runSession(MNN::Session*) const", referenced from:
      APP::Objects::AIManager::runMNNModel(AICorrectorParameters&, MNNAlgoVersion) in AIManager.o
  "MNN::Tensor::copyToHostTensor(MNN::Tensor*) const", referenced from:
      APP::Objects::AIManager::runMNNModel(AICorrectorParameters&, MNNAlgoVersion) in AIManager.o
  "MNN::Tensor::getDimensionType() const", referenced from:
      createTensor(MNN::Tensor const*, AICorrectorParameters const&, MNNAlgoVersion) in AIManager.o
      APP::Objects::AIManager::runMNNModel(AICorrectorParameters&, MNNAlgoVersion) in AIManager.o
  "MNN::Tensor::size() const", referenced from:
      APP::Objects::AIManager::runMNNModel(AICorrectorParameters&, MNNAlgoVersion) in AIManager.o
  "MNN::Tensor::shape() const", referenced from:
      APP::Objects::AIManager::runMNNModel(AICorrectorParameters&, MNNAlgoVersion) in AIManager.o
ld: symbol(s) not found for architecture arm64 ```

LeoCloser avatar Jan 31 '24 19:01 LeoCloser

MNN be compiled in Apple M1 max. You must assume MNN's ARCHITECTUR is the same as your library. Try add cmake .. -DCMAKE_OSX_ARCHITECTURES=armv8 to set as arm

jxt1234 avatar Feb 05 '24 02:02 jxt1234