mlc-ai / mlc-llm

Universal LLM Deployment Engine with ML Compilation
https://llm.mlc.ai/
Apache License 2.0
19.08k stars 1.56k forks source link

[Bug] error: model_lib/libmodel_android.a(._lib0.o): not an ELF file #1580

Closed taeyeonlee closed 9 months ago

taeyeonlee commented 9 months ago

🐛 Bug

I'm trying build android app but got an error with error: model_lib/libmodel_android.a(._lib0.o): not an ELF file when excuting ./prepare_libs.sh. Whats wrong and how to fix it?

To Reproduce

Steps to reproduce the behavior: https://llm.mlc.ai/docs/deploy/android.html

  1. tvm build successful with libtvm_runtime.so/libtvm.so outputed.
  2. use the defaul file : app-config.json { "model_libs": [ "llama_q4f16_1", "gpt_neox_q4f16_1" ], "model_list": [ { "model_url": "https://huggingface.co/mlc-ai/Llama-2-7b-chat-hf-q4f16_1-MLC/", "local_id": "Llama-2-7b-chat-hf-q4f16_1", "model_lib_path": "libs/Llama-2-7b-chat-hf-q4f16_1-android.tar", "model_lib": "llama_q4f16_1" }, { "model_url": "https://huggingface.co/mlc-ai/RedPajama-INCITE-Chat-3B-v1-q4f16_1-MLC/", "local_id": "RedPajama-INCITE-Chat-3B-v1-q4f16_1", "model_lib_path": "libs/RedPajama-INCITE-Chat-3B-v1-q4f16_1-android.tar", "model_lib": "gpt_neox_q4f16_1" } ] }
  3. download the prebuilt lib : from https://github.com/mlc-ai/binary-mlc-llm-libs/tree/main ./dist/libs/Llama-2-7b-chat-hf-q4f16_1-android.tar ./dist/libs/RedPajama-INCITE-Chat-3B-v1-q4f16_1-android.tar
  4. excute ./prepare_libs.sh
    the error is following.

taeyeonlee@taeyeonlee-15U50Q-SP7PL:~/mlc-llm/android/library$ ./prepare_libs.sh

-- TVM_HOME: /home/taeyeonlee/mlc-llm/android/library/../../3rdparty/tvm -- JNI_INCLUDE_DIRS=/usr/lib/jvm/java-17-openjdk-amd64/include;/usr/lib/jvm/java-17-openjdk-amd64/include/linux;/usr/lib/jvm/java-17-openjdk-amd64/include -- JNI_LIBRARIES=/usr/lib/jvm/java-17-openjdk-amd64/lib/libjawt.so;/usr/lib/jvm/java-17-openjdk-amd64/lib/server/libjvm.so -- Configuring done -- Generating done -- Build files have been written to: /home/taeyeonlee/mlc-llm/android/library/build

Expected behavior

build successful

Environment

BakingBrains commented 9 months ago

Any solution here?

BakingBrains commented 9 months ago

I facing similar issue

[ 93%] Building CXX object mlc_llm/CMakeFiles/mlc_llm_objs.dir/cpp/streamer.cc.o
[ 93%] Building CXX object mlc_llm/CMakeFiles/mlc_llm_objs.dir/cpp/tokenizers.cc.o
1 warning generated.
[ 93%] Built target mlc_llm_objs
[ 93%] Built target tvm_runtime_objs
make[1]: *** [CMakeFiles/Makefile2:275: CMakeFiles/tvm4j_runtime_packed.dir/rule] Error 2
make: *** [Makefile:203: tvm4j_runtime_packed] Error 2

Any suggestions here?

Thank you

BakingBrains commented 9 months ago

@taeyeonlee any solution here?

Facing the same error

ld.lld: error: model_lib/libmodel_android.a(._lib0.o): not an ELF file
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
make[3]: *** [CMakeFiles/tvm4j_runtime_packed.dir/build.make:104: libtvm4j_runtime_packed.so] Error 1
make[2]: *** [CMakeFiles/Makefile2:268: CMakeFiles/tvm4j_runtime_packed.dir/all] Error 2
make[1]: *** [CMakeFiles/Makefile2:275: CMakeFiles/tvm4j_runtime_packed.dir/rule] Error 2
make: *** [Makefile:203: tvm4j_runtime_packed] Error 2
Kartik14 commented 9 months ago

@taeyeonlee @BakingBrains This should fix it, can you please try to download the prebuilt libs again and check?

BakingBrains commented 9 months ago

@Kartik14 It's working thanks