pytorch build for android was completed as follows.
$ ANDROID_NDK=.../android-ndk-r21e
$ ANDROID_ABI="arm64-v8a"
$ cd scripts
$ ./build_android.sh
... (long time) ...
[100%] Linking CXX static library ../lib/libtorch.a
[100%] Built target torch
Install the project...
-- Install configuration: "Release"
Installation completed, now you can copy the headers/libs from /mnt/HDD_2TB/greenfish/pytorch_build/work.trial9/pytorch/build_android/install to your Android project directory.
the install dir is as follows.
/mnt/HDD_2TB/greenfish/pytorch_build/work.trial9/pytorch/build_android/install
├── include
│ ├── ATen
│ ├── TH
│ ├── THCUNN
│ ├── c10
│ ├── caffe2
│ ├── fp16
│ ├── pybind11
│ └── torch
├── lib
└── share
├── ATen
└── cmake
example code:
/mnt/HDD_2TB/greenfish/pytorch_build/work.trial9/src/test.cpp
#include <torch/torch.h>
#include <iostream>
int main() {
torch::Tensor tensor = torch::eye(3);
std::cout << tensor << std::endl;
}
/mnt/HDD_2TB/greenfish/pytorch_build/work.trial9/src/CMakeLists.txt
cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
project(test)
find_package(Torch REQUIRED)
add_executable(test test.cpp)
target_link_libraries(test "${TORCH_LIBRARIES}")
set_property(TARGET test PROPERTY CXX_STANDARD 14)
build
src$ mkdir build
src$ cd build
build$ cmake ..
...
...
...
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:4 (find_package):
By not providing "FindTorch.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Torch", but
CMake did not find one.
Could not find a package configuration file provided by "Torch" with any of
the following names:
TorchConfig.cmake
torch-config.cmake
Add the installation prefix of "Torch" to CMAKE_PREFIX_PATH or set
"Torch_DIR" to a directory containing one of the above files. If "Torch"
provides a separate development package or SDK, be sure it has been
installed.
Passing the CMAKE_MODULE_PATH
and CMAKE_PREFIX_PATH
values did not work.
How can I pass the install directory?