Libtorch_cxx11_ABI static library

aramir23: <p>Hi everyone, i tried downloading cxx11-ABI static libtorch <a href="https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-static-with-deps-2.4.1%2Bcpu.zip" rel="noopener nofollow ugc">https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-static-with-deps-2.4.1%2Bcpu.zip</a> but i got access denied error. But for pre-cxx11 it works fine.<br>
Is there any other link or its just not publicly available ? If so how can i link libtorch statically. I need the CXX11 version since pre_CXX11 is not compatible with OpenCV somehow. I’m using Ubuntu 24.04 and i tend to create a docker container of my project.</p>

malfet: <p>Can you please share a link to to 2.4.1 pre-cxx11 binary you are referring to.</p>
<p>We’ve stopped building static binaries around (see <a href="https://github.com/pytorch/pytorch/pull/112452" class="inline-onebox" rel="noopener nofollow ugc">[CI] Limit libtorch builds to `shared-with-deps` by malfet · Pull Request #112452 · pytorch/pytorch · GitHub</a> ), because CUDA runtime can no longer be linked statically, it has lots of performance and memory implications compaed to dynamically linked libraries, and usually if one needs to link statically, why not build PyTorch from source with whatever dependencies needed for a specific project?</p>

ptrblck: <aside class="quote no-group" data-username="malfet" data-post="2" data-topic="211309">
<div class="title">
<div class="quote-controls"></div>
<img loading="lazy" alt="" width="24" height="24" src="https://discuss.pytorch.org/user_avatar/discuss.pytorch.org/malfet/48/27485_2.png" class="avatar"> malfet:</div>
<blockquote>
<p>because CUDA runtime can no longer be linked statically, it has lots of performance and memory implications compaed to dynamically linked libraries</p>
</blockquote>
</aside>
<p>Are you sure about CUDA runtime or are you referring to e.g. cuDNN, which had issues when statically linked in the past?<br>
Statically linking the CUDA runtime into an application is a common approach and I’m not aware of any issues with it.</p>

aramir23: <p>Download here (Pre-cxx11 ABI):<br>
<a href="https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.4.1%2Bcpu.zip" class="onebox" target="_blank" rel="noopener nofollow ugc">https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.4.1%2Bcpu.zip</a><br>
Download here (cxx11 ABI):<br>
<a href="https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.4.1%2Bcpu.zip" class="onebox" target="_blank" rel="noopener nofollow ugc">https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.4.1%2Bcpu.zip</a></p>
<p>these are the two links I’m refering to, they are both available at pytorch homepage. if  i change the shared to static as <a href="https://download.pytorch.org/libtorch/cpu/libtorch-static-with-deps-2.4.1%2Bcpu.zip" rel="noopener nofollow ugc">https://download.pytorch.org/libtorch/cpu/libtorch-static-with-deps-2.4.1%2Bcpu.zip</a> i can download static libs for pre CXX11. But i need CXX11 since I’ll be using opencv as well. And also I’m sticking to the cpu for now, I dont tend to use cuda for this project.</p>
<p>PS : the static link throws access denied now, but i’ve downloaded it 2 days ago.</p>
<p>PS 2 : seems like older versions are available in   <a href="https://download.pytorch.org/libtorch/cpu" rel="noopener nofollow ugc">https://download.pytorch.org/libtorch/cpu</a> for static linking, which one is better ? is 2.1.2 ok ?</p>
<p>PS3: used 2.1.2, but still depends on some shared libraries, like libtorchcpu.so i dont know how to make them static</p>

malfet: <blockquote>
<p>Are you sure about CUDA runtime or are you referring to e.g. cuDNN, which had issues when statically linked in the past?</p>
</blockquote>
<p>Neither:</p>
<ul>
<li>
<p>Linking together cuDNN + cuBLAS + cuFFT + … with all supported cuda architecture results in a binary which is larger than 4Gb, and cubins still (at least of CUDA-11.X) use 32-bit relocs, which just makes in unlikable.</p>
</li>
<li>
<p><code>lincudnn_static</code> used to be built differently and were simply missing some heuristics/faster kernels that dynamic cudnn has, and so linking with it statically resulted in 10-15% slower convolutions on Ampere+</p>
</li>
</ul>

ptrblck: <p>Thanks for confirming!<br>
Yes, the cuDNN static linking issue was observed in 8.0 and fixed in later releases.<br>
Nevertheless, the overall binary size is indeed large and your 4GB limitation is valid.</p>
<p>I don’t want to diverge the thread, just wanted to learn more about issues with a statically linked CUDA Runtime (CUDART), which should not cause any issues.<br>
The other points about the reloc issues and cuDNN are valid.</p>