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

username: marchss
cooked: <p>I am trying to add libtorch C++ shared library to system library path, as shown below</p>
<pre><code class="lang-auto">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
</code></pre>
<p>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++</p>
<pre><code class="lang-auto">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
</code></pre>

username: jasjuang
cooked: <p>I encountered the same problem. Were you able to figure out a way to fix this?</p>

username: marchss
cooked: <p>not yet. I switch to other approaches. This issue is waiting for pytorch folks to help out.</p>

username: indyml
cooked: <p>I’m seeing the same issue, with truncated torchlib libraries<br>
Internet seems to suggest it is a problem with patchelf.</p>
<p>My system:</p>
<ul>
<li>gcc version 9.3.0 (Debian 9.3.0-11)</li>
<li>Debian GNU/Linux bullseye/sid</li>
</ul>
<p>What I did:</p>
<ul>
<li>Downloaded torchlib (<a href="https://download.pytorch.org/libtorch/cu102/libtorch-cxx11-abi-shared-with-deps-1.5.0.zip" rel="nofollow noopener">https://download.pytorch.org/libtorch/cu102/libtorch-cxx11-abi-shared-with-deps-1.5.0.zip</a>)</li>
<li>unzipped it to /usr/local/</li>
<li>able to successfully compile against torchlib</li>
<li>cannot execute my program, as libc10.so is not in the ld.so.cache</li>
<li>running ldconfig gives</li>
</ul>
<p>/sbin/ldconfig: file /usr/local/libtorch/lib/libnvrtc-builtins.so is truncated<br>
/sbin/ldconfig: file /usr/local/libtorch/lib/libnvrtc-08c4863f.so.10.2 is truncated<br>
/sbin/ldconfig: file /usr/local/libtorch/lib/libcaffe2_nvrtc.so is truncated<br>
/sbin/ldconfig: file /usr/local/libtorch/lib/libcaffe2_detectron_ops_gpu.so is truncated<br>
/sbin/ldconfig: file /usr/local/libtorch/lib/libc10.so is truncated<br>
/sbin/ldconfig: file /usr/local/libtorch/lib/libc10_cuda.so is truncated<br>
/sbin/ldconfig: file /usr/local/libtorch/lib/libc10d_cuda_test.so is truncated<br>
/sbin/ldconfig: file /usr/local/libtorch/lib/libtorch_global_deps.so is truncated<br>
/sbin/ldconfig: file /usr/local/libtorch/lib/libnvToolsExt-3965bdd0.so.1 is truncated<br>
/sbin/ldconfig: file /usr/local/libtorch/lib/libcudart-80664282.so.10.2 is truncated<br>
/sbin/ldconfig: file /usr/local/libtorch/lib/libgomp-75eea7e8.so.1 is truncated</p>

username: superlyy
cooked: <p>Having the same issue as above.</p>

username: indyml
cooked: <p>Found the issue and a fix or two:</p>
<p>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.<br>
See this issue, <a href="https://sourceware.org/bugzilla/show_bug.cgi?id=25087" rel="nofollow noopener">https://sourceware.org/bugzilla/show_bug.cgi?id=25087</a>.  You can confirm that this is your issue by looking at the section order with readelf -S</p>
<p>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.</p>

username: xingwenzhi
cooked: <p>Hi, could you share your final solution?  I’m seeing the same issue.If possible, glad to receive your reply.</p>

username: ompugao
cooked: <p>I still have the same issue with libtorch 1.13.0 on ubuntu 18.04.<br>
I had to build libtorch from source code.</p>