I can't build for LibTorch on aarch64. Cannot find libcublas.so

I’m trying to install LibTorch on a Jetson AGX Xavier.
I do a recursive git clone of this pytorch repo and run 'python3 tools/build_libtorch.py.
The build fails with the following error

FAILED: lib/libtorch_global_deps.so
: && /usr/bin/cc -fPIC -fopenmp -DNDEBUG -O3 -DNDEBUG -DNDEBUG -Wl,–no-as-needed -rdynamic -shared -Wl,-soname,libtorch_global_deps.so -o lib/libtorch_global_deps.so caffe2/CMakeFiles/torch_global_deps.dir/__/torch/csrc/empty.c.o -Wl,-rpath,/usr/lib/aarch64-linux-gnu/openmpi/lib:/usr/local/cuda/lib64:::::::: /usr/lib/aarch64-linux-gnu/openmpi/lib/libmpi_cxx.so /usr/lib/aarch64-linux-gnu/openmpi/lib/libmpi.so /usr/local/cuda/lib64/libcurand.so /usr/local/cuda/lib64/libcufft.so -lCUDA_cublas_LIBRARY-NOTFOUND /usr/lib/aarch64-linux-gnu/libcudnn.so /usr/local/cuda/lib64/libcudart.so /usr/local/cuda/lib64/libnvToolsExt.so && :
/usr/bin/ld: cannot find -lCUDA_cublas_LIBRARY-NOTFOUND
collect2: error: ld returned 1 exit status
[2357/3927] Building CXX object c10/test/CMakeFiles/c10_intrusive_ptr_test.dir/util/intrusive_ptr_test.cpp.o
ninja: build stopped: subcommand failed.


JetPack 4.6
Nvidia Jetson AGX Xavier
The current pytorch repo available on GitHub.


cannot find -lCUDA_cublas_LIBRARY-NOTFOUND

Based on the log, the compiler cannot find the CUDA library in your environment.
When you set up Xavier with JetPack4.6, do you also install all the components with SDK manager?


I was using Python3.6, and I was able to end up installing LibTorch with Python3.8.
I had regular PyTorch installed with Python3.6, so I didn’t know it was a problem.
Fully installed with the github Pytorch repo and tools/build_libtorch.py.