Libtorch C++ *.so files truncated error when ldconfig

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
2 Likes

I encountered the same problem. Were you able to figure out a way to fix this?

not yet. I switch to other approaches. This issue is waiting for pytorch folks to help out.

I’m seeing the same issue, with truncated torchlib libraries
Internet seems to suggest it is a problem with patchelf.

My system:

  • gcc version 9.3.0 (Debian 9.3.0-11)
  • Debian GNU/Linux bullseye/sid

What I did:

/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

3 Likes

Having the same issue as above.

Found the issue and a fix or two:

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.

Hi, could you share your final solution? I’m seeing the same issue.If possible, glad to receive your reply.