How to build libtorch for aarch64?

What is the right way to cross-compile libtorch for aarch64 target on an amd64 Linux host?

I’m currently using tools/build_libtorch.py, however, when I try to use this library to build my C++ code using, cmake -DCMAKE_PREFIX_PATH=/path/to/build_libtorch .., I get errors regarding missing header files and libcaffe2_gpu.so.

Is there a script or a tutorial that would help organize the libtorch library similar to the structure released on the downloads page?

libtorch/
  bin/
  include/
  lib/
  share/

You might try to follow the route android takes, providing a CMAKE_TOOLCHAIN_FILE and you might need a host protobuf, see scripts/build_android.sh for inspiration.
I will admit that I did not try but build natively on aarch64 for the time being…

Best regards

Thomas