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?
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…
For 1) you can build PyTorch natively on the largest Raspberry Pi 4 or NVidia Jetsons pretty much by running setup.py. 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.
Thanks for your response Tom, Finally I make it work on Jetson Nano, by just using python3 setup.py 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