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/, 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

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


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

Best regards


Any update on this I tray to built it myself too, I got an error when I try simple c++ example from the official website

So this has two parts:

  1. Build libtorch on aarch64,
  2. build libtorch on Android.

Which one are you most interested in?

For 1) you can build PyTorch natively on the largest Raspberry Pi 4 or NVidia Jetsons pretty much by running The caveat is that the build may (will) crash with out of memory if you run with -j4. My solution to that has been to then build the large C++ with -j1 and afterwards continue with -j4. More fancy things like distcc probably get better results yet.

For 2) check out the Pytorch mobile build instructions.

Best regards



Thanks for your response Tom, Finally I make it work on Jetson Nano, by just using python3 install . The problem was I built libtorch without cxx 11 abi activated. I reinstall it with cxx 11 abi = 1, run /usr/bin/jetson_clock and I used 1G swap file. works like charm, no crash, it took about 12 hours to complete


Would it be possible for you to leave a few more breadcrumbs about how you did this?
There is very written about how to get LibTorch on a Jetson.

You wrote

using python3 install . The problem was I built libtorch without cxx 11 abi activated

Would it be possible for you to post the contents if you still have these files with your modifications?