I am trying to add libtorch C++ shared library to system library path, as shown below
root@:/etc#cat ld.so.conf.d/local.conf
/usr/local/torch_lib
root@:/etc#
root@:/etc#
root@:/etc#cat ld.so.conf
include ld.so.conf.d/*.conf
It gives lots of truncated errors. How shall this be fixed? I tried both the officially provided libtorch C++ library and my own built libtorch C++
ldconfig: file /usr/local/torch_lib/libc10_cuda.so is truncated
ldconfig: file /usr/local/torch_lib/libcaffe2_detectron_ops_gpu.so is truncated
ldconfig: file /usr/local/torch_lib/libthnvrtc.so is truncated
ldconfig: file /usr/local/torch_lib/libcudart-f7fdd8d7.so.9.0 is truncated
ldconfig: file /usr/local/torch_lib/libnvrtc-builtins.so is truncated
ldconfig: file /usr/local/torch_lib/libnvToolsExt-3965bdd0.so.1 is truncated
ldconfig: file /usr/local/torch_lib/libnvrtc-007d19c9.so.9.0 is truncated
ldconfig: file /usr/local/torch_lib/libgomp-4f651535.so.1 is truncated
cannot execute my program, as libc10.so is not in the ld.so.cache
running ldconfig gives
/sbin/ldconfig: file /usr/local/libtorch/lib/libnvrtc-builtins.so is truncated
/sbin/ldconfig: file /usr/local/libtorch/lib/libnvrtc-08c4863f.so.10.2 is truncated
/sbin/ldconfig: file /usr/local/libtorch/lib/libcaffe2_nvrtc.so is truncated
/sbin/ldconfig: file /usr/local/libtorch/lib/libcaffe2_detectron_ops_gpu.so is truncated
/sbin/ldconfig: file /usr/local/libtorch/lib/libc10.so is truncated
/sbin/ldconfig: file /usr/local/libtorch/lib/libc10_cuda.so is truncated
/sbin/ldconfig: file /usr/local/libtorch/lib/libc10d_cuda_test.so is truncated
/sbin/ldconfig: file /usr/local/libtorch/lib/libtorch_global_deps.so is truncated
/sbin/ldconfig: file /usr/local/libtorch/lib/libnvToolsExt-3965bdd0.so.1 is truncated
/sbin/ldconfig: file /usr/local/libtorch/lib/libcudart-80664282.so.10.2 is truncated
/sbin/ldconfig: file /usr/local/libtorch/lib/libgomp-75eea7e8.so.1 is truncated
The issue seems to be caused by patchelf, which alters the order of sections in a way that ldconfig and libc libraries for do not deal with prior to libc version 2.31.
See this issue, https://sourceware.org/bugzilla/show_bug.cgi?id=25087. You can confirm that this is your issue by looking at the section order with readelf -S
I’m currently on glibc 2.30, and upgrading would be a big task and risk bricking my Linux install. So instead I built libtorch from source. The compilation at least on my system does not appear to use patchelf, so building it myself fixes the issue. Followed the instruction in the release notes and it went easily.