How does one use LibTorch (C++) with the Arch64 build of PyTorch for the Nvidia Jetson?

There is a way to use Libtorch on the nvidia jetson platform.

The Pytorch official has not provided an aarch64 Libtorch package for downloading, It only provides an x86-64 Libtorch package。

In the Nvidia Jetson platform, Nvidia provides the PyTorch python package, which contains Libtorch in it.
So, We can use Libtorch by installing the Pytorch Python package.

Firstly, you should download PyTorch for Jetson on below link

https://forums.developer.nvidia.com/t/pytorch-for-jetson/72048

Secondly, install the “whl” file following this guide

[Installing PyTorch for Jetson Platform - NVIDIA Docs]

After you finished the above steps. The LibTorch has been installed on your device.

How to Use?

where is LibTorch installed?

Commonly, it installs at ~/.local/lib/python3.6/site-packages/torch/
In this dir, you can see bin, lib, and include dir, It is organized just like other C++ libraries.

How to use LibTorch with CMake?

for example, add these two lines to your CMakeLists.txt

// set PyTorch path
set(Torch_DIR /home/nx/.local/lib/python3.6/site-packages/torch/share/cmake/Torch)
// use find_package to use libtorch
find_package(Torch REQUIRED)