cool-easter-32542
11/18/2023, 1:52 PMpex_binary together with torch>=1.13 may encounter weird _dl_open errors in relation to CUDA libraries. The same lockfile, same code, works when using python_source instead. This indicates that there is some difference in how the pex and/or venv is built between these two cases that causes one to fail unexpectedly.
The solution is simply to import nvidia before loading torch. For both packed and loose pex's this seems to cause all nvidia packages to install correctly, and work. This is a huge footgun, because transitive dependencies should be available no matter. I'm going to guess nothing actually imports these packages in torch either, as they contain no actual code... only `.so`s.
Pants version
2.18
OS
Can only occur on Linux.
Additional info
Runnable repro here: https://github.com/tgolsson/pants-repros/tree/main/torch-2
Slack thread here: https://pantsbuild.slack.com/archives/C046T6T9U/p1700184172636389
pantsbuild/pants