Xavier libtorch support

Hi,

I’m trying to get some code compiled with libtorch on Xaiver. I built the libtorch using the guide [here]https://devtalk.nvidia.com/default/topic/1049071/jetson-nano/pytorch-for-jetson-nano/, and used

python setup.py develop

at the end of the process.

However, I’m not entirely sure if libtorch got built correctly as I couldn’t find the correct path to the cmake include directory. Does anyone have experience setting up libtorch on Jetson devices? Thanks!

I’m running Jetpack 4.3

could you extend which steps you are executing and what is the exact output?

Hi hengruiz, I found libtorch on my system here:

$ find ~ -name '*libtorch*'
./.local/lib/python3.6/site-packages/torch/lib/libtorch.so

This was after I installed the wheel for Python 3.6. The headers are in ~/.local/lib/python3.6/site-packages/torch/include. I believe setup.py develop does a similar structure, just using symbolic links to your local source tree.

Hi dusty,

Thanks for the reply! I installed pytorch again with the wheel and try to link using the ./.local/lib path, but I got the following error during the build process of my program:

/usr/bin/ld: cannot find -lCUDA_cublas_device_LIBRARY-NOTFOUND
collect2: error: ld returned 1 exit status

Have you encountered this issue before? Thanks!

Are you using cmake and find_package(CUDA)? It looks like an issue unrelated to PyTorch - that it can’t find cuBLAS location.

Are these lines below in your ~/.bashrc config? If not, can you try adding them to the end of your ~/.bashrc, and then restarting your terminal?

export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}$
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

These paths should help CMake find your CUDA install.

Yes these lines are in my bashrc.
The problem was solved by upgrading cmake from 3.10 to 3.15, not sure why…
Thanks!