pytorch / executorch

On-device AI across mobile, embedded and edge for PyTorch
https://pytorch.org/executorch/
Other
1.94k stars 322 forks source link

Runtime Error: Incompatibility During Build for Android (qnn_executor_runner) #6219

Open LLIKKE opened 2 days ago

LLIKKE commented 2 days ago

🐛 Describe the bug

I was following the tutorial to build qnn_executor_runner for Android as outlined below:

cd $EXECUTORCH_ROOT
mkdir build-android
cd build-android
# build executorch & qnn_executorch_backend
cmake .. \
    -DCMAKE_INSTALL_PREFIX=$PWD \
    -DEXECUTORCH_BUILD_QNN=ON \
    -DQNN_SDK_ROOT=$QNN_SDK_ROOT \
    -DEXECUTORCH_BUILD_DEVTOOLS=ON \
    -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
    -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
    -DEXECUTORCH_ENABLE_EVENT_TRACER=ON \
    -DPYTHON_EXECUTABLE=python3 \
    -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
    -DANDROID_ABI='arm64-v8a' \
    -DANDROID_NATIVE_API_LEVEL=23

cmake --build $PWD --target install -j$(nproc)

cmake ../examples/qualcomm \
    -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK_ROOT/build/cmake/android.toolchain.cmake \
    -DANDROID_ABI='arm64-v8a' \
    -DANDROID_NATIVE_API_LEVEL=23 \
    -DCMAKE_PREFIX_PATH="$PWD/lib/cmake/ExecuTorch;$PWD/third-party/gflags;" \
    -DCMAKE_FIND_ROOT_PATH_MODE_PACKAGE=BOTH \
    -DPYTHON_EXECUTABLE=python3 \
    -Bexamples/qualcomm

cmake --build examples/qualcomm -j$(nproc)

# qnn_executor_runner can be found under examples/qualcomm
# The full path is $EXECUTORCH_ROOT/build-android/examples/qualcomm/qnn_executor_runner
ls examples/qualcomm

However, when I run the build process, I encounter the following error:

[ 95%] Linking CXX executable qnn_executor_runner
[ 95%] Linking CXX executable qnn_llama_runner
ld.lld: error: /home/like/executorch/executorch4/executorch/build-android/lib/libflatccrt_d.a(builder.c.o) is incompatible with aarch64linux
ld.lld: error: /home/like/executorch/executorch4/executorch/build-android/lib/libflatccrt_d.a(emitter.c.o) is incompatible with aarch64linux
ld.lld: error: /home/like/executorch/executorch4/executorch/build-android/lib/libflatccrt_d.a(refmap.c.o) is incompatible with aarch64linux
ld.lld: error: /home/like/executorch/executorch4/executorch/build-android/lib/libflatccrt_d.a(verifier.c.o) is incompatible with aarch64linux
ld.lld: error: /home/like/executorch/executorch4/executorch/build-android/lib/libflatccrt_d.a(json_parser.c.o) is incompatible with aarch64linux
ld.lld: error: /home/like/executorch/executorch4/executorch/build-android/lib/libflatccrt_d.a(json_printer.c.o) is incompatible with aarch64linux
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[2]: *** [executor_runner/CMakeFiles/qnn_executor_runner.dir/build.make:185: executor_runner/qnn_executor_runner] Error 1
gmake[1]: *** [CMakeFiles/Makefile2:785: executor_runner/CMakeFiles/qnn_executor_runner.dir/all] Error 2
gmake[1]: *** Waiting for unfinished jobs....
[ 98%] Built target qnn_llama_runner
gmake: *** [Makefile:136: all] Error 2

It seems like there’s an issue with the compatibility of libflatccrt_d.a with aarch64linux. Could you help me understand what might be going wrong or how to resolve this error?

Versions

For security purposes, please check the contents of collect_env.py before running it.

python collect_env.py --2024-10-15 11:24:43-- https://raw.githubusercontent.com/pytorch/pytorch/main/torch/utils/collect_env.py Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 185.199.109.133, 185.199.110.133, 185.199.108.133, ... Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|185.199.109.133|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 23357 (23K) [text/plain] Saving to: ‘collect_env.py’

collect_env.py 100%[======================================>] 22.81K --.-KB/s in 0.04s

2024-10-15 11:24:44 (562 KB/s) - ‘collect_env.py’ saved [23357/23357]

Collecting environment information... PyTorch version: 2.6.0.dev20241007+cpu Is debug build: False CUDA used to build PyTorch: Could not collect ROCM used to build PyTorch: N/A

OS: Ubuntu 22.04.3 LTS (x86_64) GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0 Clang version: 14.0.0-1ubuntu1.1 CMake version: version 3.30.4 Libc version: glibc-2.35

Python version: 3.10.0 (default, Mar 3 2022, 09:58:08) [GCC 7.5.0] (64-bit runtime) Python platform: Linux-5.15.153.1-microsoft-standard-WSL2-x86_64-with-glibc2.35 Is CUDA available: False CUDA runtime version: Could not collect CUDA_MODULE_LOADING set to: N/A GPU models and configuration: GPU 0: NVIDIA GeForce RTX 3050 4GB Laptop GPU Nvidia driver version: 527.83 cuDNN version: Could not collect HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 39 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 8 On-line CPU(s) list: 0-7 Vendor ID: GenuineIntel Model name: 13th Gen Intel(R) Core(TM) i5-13500H CPU family: 6 Model: 186 Thread(s) per core: 2 Core(s) per socket: 4 Socket(s): 1 Stepping: 2 BogoMIPS: 6374.43 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ss ht syscall nx pdpe1gb rdtscp lm constant_tsc rep_good nopl xtopology tsc_reliable nonstop_tsc cpuid pni pclmulqdq vmx ssse3 fma cx16 sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch ssbd ibrs ibpb stibp ibrs_enhanced tpr_shadow vnmi ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves avx_vnni umip waitpkg gfni vaes vpclmulqdq rdpid movdiri movdir64b fsrm md_clear serialize flush_l1d arch_capabilities Virtualization: VT-x Hypervisor vendor: Microsoft Virtualization type: full L1d cache: 192 KiB (4 instances) L1i cache: 128 KiB (4 instances) L2 cache: 5 MiB (4 instances) L3 cache: 18 MiB (1 instance) Vulnerability Gather data sampling: Not affected Vulnerability Itlb multihit: Not affected Vulnerability L1tf: Not affected Vulnerability Mds: Not affected Vulnerability Meltdown: Not affected Vulnerability Mmio stale data: Not affected Vulnerability Retbleed: Mitigation; Enhanced IBRS Vulnerability Spec rstack overflow: Not affected Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl and seccomp Vulnerability Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitization Vulnerability Spectre v2: Mitigation; Enhanced IBRS, IBPB conditional, RSB filling, PBRSB-eIBRS SW sequence Vulnerability Srbds: Not affected Vulnerability Tsx async abort: Not affected

Versions of relevant libraries: [pip3] executorch==0.5.0a0+bff26f3 [pip3] numpy==1.26.4 [pip3] torch==2.6.0.dev20241007+cpu [pip3] torchao==0.5.0+git0916b5b2 [pip3] torchaudio==2.5.0.dev20241007+cpu [pip3] torchsr==1.0.4 [pip3] torchvision==0.20.0.dev20241007+cpu [conda] executorch 0.5.0a0+bff26f3 pypi_0 pypi [conda] numpy 1.26.4 pypi_0 pypi [conda] torch 2.6.0.dev20241007+cpu pypi_0 pypi [conda] torchao 0.5.0+git0916b5b2 pypi_0 pypi [conda] torchaudio 2.5.0.dev20241007+cpu pypi_0 pypi [conda] torchsr 1.0.4 pypi_0 pypi [conda] torchvision 0.20.0.dev20241007+cpu pypi_0 pypi

shewu-quic commented 1 day ago

Hi @LLIKKE Have you tried running this script instead?

sh backends/qualcomm/scripts/build.sh