Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CMake Error missing TORCH_LIBRARY in Android Llama XNNPACK Demo Build #8556

Open
sskarz opened this issue Feb 19, 2025 · 1 comment · May be fixed by #8629
Open

CMake Error missing TORCH_LIBRARY in Android Llama XNNPACK Demo Build #8556

sskarz opened this issue Feb 19, 2025 · 1 comment · May be fixed by #8629
Assignees
Labels
module: android Issues related to Android code, build, and execution module: user experience Issues related to reducing friction for users triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module

Comments

@sskarz
Copy link

sskarz commented Feb 19, 2025

Getting an error when building the CMake Android Extension for the XNNPACK backend. Followed the instructions on the Llama readme.

Observed result:

(executorch) sanskarthapa@mac executorch % 
cmake -DCMAKE_TOOLCHAIN_FILE=$ANDROID_NDK/build/cmake/android.toolchain.cmake \
    -DANDROID_ABI=arm64-v8a \
    -DANDROID_PLATFORM=android-23 \
    -DCMAKE_INSTALL_PREFIX=cmake-out-android \
    -DCMAKE_BUILD_TYPE=Release \
    -DEXECUTORCH_BUILD_EXTENSION_DATA_LOADER=ON \
    -DEXECUTORCH_BUILD_EXTENSION_MODULE=ON \
    -DEXECUTORCH_BUILD_EXTENSION_TENSOR=ON \
    -DEXECUTORCH_ENABLE_LOGGING=1 \
    -DPYTHON_EXECUTABLE=python \
    -DEXECUTORCH_BUILD_XNNPACK=ON \
    -DEXECUTORCH_BUILD_KERNELS_OPTIMIZED=ON \
    -DEXECUTORCH_BUILD_KERNELS_QUANTIZED=ON \
    -DEXECUTORCH_BUILD_KERNELS_CUSTOM=ON \
    -Bcmake-out-android .

cmake --build cmake-out-android -j16 --target install --config Release
CMake Deprecation Warning at /Users/sanskarthapa/Library/Android/sdk/ndk/26.1.10909125/build/cmake/android.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  cmake-out-android/CMakeFiles/3.31.5/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:46 (project)


CMake Deprecation Warning at /Users/sanskarthapa/Library/Android/sdk/ndk/26.1.10909125/build/cmake/android-legacy.toolchain.cmake:34 (cmake_minimum_required):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.
Call Stack (most recent call first):
  /Users/sanskarthapa/Library/Android/sdk/ndk/26.1.10909125/build/cmake/android.toolchain.cmake:54 (include)
  cmake-out-android/CMakeFiles/3.31.5/CMakeSystem.cmake:6 (include)
  CMakeLists.txt:46 (project)


CMake Deprecation Warning at backends/xnnpack/third-party/FXdiv/CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


CMake Deprecation Warning at backends/xnnpack/third-party/cpuinfo/CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


CMake Deprecation Warning at backends/xnnpack/third-party/pthreadpool/CMakeLists.txt:1 (CMAKE_MINIMUM_REQUIRED):
  Compatibility with CMake < 3.10 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value.  Or, use the <min>...<max> syntax
  to tell CMake that the project requires at least <min> but has been updated
  to work with policies introduced by <max> or earlier.


-- Using python executable 'python'
-- Resolved buck2 as /Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/buck2-bin/buck2-f3b7a37732803ed090cd8a37f00cc000.
-- Killing buck2 daemon
'/Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/buck2-bin/buck2-f3b7a37732803ed090cd8a37f00cc000 killall'
-- executorch: Generating source lists
-- executorch: Using source file list /Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/cmake-out-android/executorch_srcs.cmake
-- executorch: Using sources file /Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/cmake-out-android/executorch_srcs.cmake
-- Proceeding with version: 24.3.25.0
-- CMAKE_CXX_FLAGS: -g -DANDROID -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security  
-- executorch: Using PAL default 'posix'
-- Generating operator lib:
--   LIB_NAME: portable_ops_lib
--   OPS_SCHEMA_YAML: /Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/kernels/portable/functions.yaml
--   ROOT_OPS: 
--   INCLUDE_ALL_OPS: 
Command - python;-m;codegen.tools.gen_oplist;--output_path=/Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/cmake-out-android/kernels/portable/portable_ops_lib/selected_operators.yaml;--ops_schema_yaml_path="/Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/kernels/portable/functions.yaml"
-- Generating kernel bindings:
--   LIB_NAME: portable_ops_lib
--   FUNCTIONS_YAML: /Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/kernels/portable/functions.yaml
--   CUSTOM_OPS_YAML: 
--   ADD_EXCEPTION_BOUNDARY: FALSE
Generated files /Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/cmake-out-android/kernels/portable/portable_ops_lib/RegisterCodegenUnboxedKernelsEverything.cpp;/Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/cmake-out-android/kernels/portable/portable_ops_lib/Functions.h;/Users/sanskarthapa/Desktop/xnnpack_trial_3/executorch/cmake-out-android/kernels/portable/portable_ops_lib/NativeFunctions.h
-- Generating operator lib:
--   LIB_NAME: portable_ops_lib
--   KERNEL_LIBS: portable_kernels
--   DEPS: executorch
'python' '-c' 'import torch as _; print(_.__path__[0], end='')'
CMake Warning at /opt/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:22 (message):
  static library c10_LIBRARY-NOTFOUND not found.
Call Stack (most recent call first):
  /opt/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:70 (append_torchlib_if_found)
  build/Utils.cmake:386 (find_package)
  build/Utils.cmake:344 (find_package_torch)
  CMakeLists.txt:623 (find_package_torch_headers)


CMake Warning at /opt/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:22 (message):
  static library kineto_LIBRARY-NOTFOUND not found.
Call Stack (most recent call first):
  /opt/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:125 (append_torchlib_if_found)
  build/Utils.cmake:386 (find_package)
  build/Utils.cmake:344 (find_package_torch)
  CMakeLists.txt:623 (find_package_torch_headers)


CMake Error at /opt/homebrew/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:233 (message):
  Could NOT find Torch (missing: TORCH_LIBRARY)
Call Stack (most recent call first):
  /opt/homebrew/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:603 (_FPHSA_FAILURE_MESSAGE)
  /opt/anaconda3/envs/executorch/lib/python3.10/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:175 (find_package_handle_standard_args)
  build/Utils.cmake:386 (find_package)
  build/Utils.cmake:344 (find_package_torch)
  CMakeLists.txt:623 (find_package_torch_headers)

-- Configuring incomplete, errors occurred!
make: Makefile: No such file or directory
make: *** No rule to make target `Makefile'.  Stop.

Versions

PyTorch version: 2.7.0.dev20250131
Is debug build: False
CUDA used to build PyTorch: None
ROCM used to build PyTorch: N/A

OS: macOS 15.1 (arm64)
GCC version: Could not collect
Clang version: 16.0.0 (clang-1600.0.26.6)
CMake version: version 3.31.5
Libc version: N/A

Python version: 3.10.0 (default, Mar 3 2022, 03:54:28) [Clang 12.0.0 ] (64-bit runtime)
Python platform: macOS-15.1-arm64-arm-64bit
Is CUDA available: False
CUDA runtime version: No CUDA
CUDA_MODULE_LOADING set to: N/A
GPU models and configuration: No CUDA
Nvidia driver version: No CUDA
cuDNN version: No CUDA
HIP runtime version: N/A
MIOpen runtime version: N/A
Is XNNPACK available: True

CPU:
Apple M2 Max

Versions of relevant libraries:
[pip3] executorch==0.6.0a0+7bab59f
[pip3] numpy==2.2.3
[pip3] torch==2.7.0.dev20250131
[pip3] torchao==0.8.0+git11333ba2
[pip3] torchaudio==2.6.0.dev20250131
[pip3] torchsr==1.0.4
[pip3] torchvision==0.22.0.dev20250131
[conda] executorch 0.6.0a0+7bab59f pypi_0 pypi
[conda] numpy 2.2.3 pypi_0 pypi
[conda] torch 2.7.0.dev20250131 pypi_0 pypi
[conda] torchao 0.8.0+git11333ba2 pypi_0 pypi
[conda] torchaudio 2.6.0.dev20250131 pypi_0 pypi
[conda] torchsr 1.0.4 pypi_0 pypi
[conda] torchvision 0.22.0.dev20250131 pypi_0 pypi

cc @kirklandsign @cbilgin @mergennachin @byjlw

@swolchok swolchok added the module: android Issues related to Android code, build, and execution label Feb 19, 2025
@swolchok swolchok added the triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module label Feb 19, 2025
@swolchok
Copy link
Contributor

JFYI @kirklandsign I had a similar problem trying to build the demo on my Mac and I have a TODO list item to try to fix it (I don't understand how the way we find Torch headers works on Android at all) ; if there does in fact seem to be something broken rather than user error, feel free to assign to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module: android Issues related to Android code, build, and execution module: user experience Issues related to reducing friction for users triaged This issue has been looked at a team member, and triaged and prioritized into an appropriate module
Projects
Status: To triage
4 participants