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.

Versions

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

libcublas.so won’t be built, but ships with the CUDA toolkit. Make sure this library was installed in the CUDA toolkit and set the CUDA path if needed. The install log should show which CUDA version was detected and where it’s located.

I ran ‘python3 tools/build_libtorch.py’ with python3.8 instead of python3.6 and it successfully installed LibTorch on my AGX Xavier.