Hi everyone, i tried downloading cxx11-ABI static libtorch https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-static-with-deps-2.4.1%2Bcpu.zip but i got access denied error. But for pre-cxx11 it works fine.
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.
Can you please share a link to to 2.4.1 pre-cxx11 binary you are referring to.
We’ve stopped building static binaries around (see [CI] Limit libtorch builds to `shared-with-deps` by malfet · Pull Request #112452 · pytorch/pytorch · GitHub ), 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?
Are you sure about CUDA runtime or are you referring to e.g. cuDNN, which had issues when statically linked in the past?
Statically linking the CUDA runtime into an application is a common approach and I’m not aware of any issues with it.
Download here (Pre-cxx11 ABI):
https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.4.1%2Bcpu.zip
Download here (cxx11 ABI):
https://download.pytorch.org/libtorch/cpu/libtorch-cxx11-abi-shared-with-deps-2.4.1%2Bcpu.zip
these are the two links I’m refering to, they are both available at pytorch homepage. if i change the shared to static as https://download.pytorch.org/libtorch/cpu/libtorch-static-with-deps-2.4.1%2Bcpu.zip 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.
PS : the static link throws access denied now, but i’ve downloaded it 2 days ago.
PS 2 : seems like older versions are available in https://download.pytorch.org/libtorch/cpu for static linking, which one is better ? is 2.1.2 ok ?
PS3: used 2.1.2, but still depends on some shared libraries, like libtorchcpu.so i dont know how to make them static
Are you sure about CUDA runtime or are you referring to e.g. cuDNN, which had issues when statically linked in the past?
Neither:
-
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.
-
lincudnn_static
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+
Thanks for confirming!
Yes, the cuDNN static linking issue was observed in 8.0 and fixed in later releases.
Nevertheless, the overall binary size is indeed large and your 4GB limitation is valid.
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.
The other points about the reloc issues and cuDNN are valid.