Change CUDA device index via Libtorch API

Libtorch C++ API seems to be having trouble detecting my Tegra CUDA device(Jetson Xavier NX), on Python3 it has no problems but on C++ it cannot. I want to set the CUDA device index using when using Libtorch on C++. How to do it?

Are you using the same libtorch? (You can take the one from PyTorch itself.)

Using the one taken from Pytorch itself. I fixed the issue after building Pytorch from source and then adding – no-as-needed in the makefile.