Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hooks: torch: suppress generation of symlinks for shared libs #836

Merged
merged 2 commits into from
Dec 3, 2024

Conversation

rokm
Copy link
Member

@rokm rokm commented Dec 3, 2024

On Linux, have the torch hook use thebindepend_symlink_suppression hook attribute to prevent PyInstaller's binary dependency analysis from creating symlinks to top-level application directory for shared libraries discovered in the torch/lib directory during binary dependency analysis.

These symbolic links confuse certain torch builds about the location of torch, and prevent torch/lib/libtorch_cuda_linalg.so from being (dynamically) loaded. The problematic builds are wheels provided by https://download.pytorch.org/whl/torch for torch 1.13.x, 2.0.x, and 2.1.x (tested with 1.13.1+cu117, 2.0.1+cu117, and 2.1.2+cu118). Later versions do not seem to be affected. The wheels provided on PyPI do not seem to be affected either, regardless of the version.

However, these symlinks should be not necessary on linux in general, so there should be no harm in suppressing them for all versions.

Fixes #834.

rokm added 2 commits December 3, 2024 22:56
Add a `torch` test that tries to solve a system of linear equations
using `torch.linalg` with input tensors stored on a CUDA device
(provided one is available).

This test shows that symbolic links created by binary dependency
analysis for shared libraries in `torch/lib` to the top-level
application directory confuse certain torch builds about the
location of `torch`, and prevent `torch/lib/libtorch_cuda_linalg.so`
from being (dynamically) loaded.
On Linux, have the `torch` hook use the`bindepend_symlink_suppression`
hook attribute to prevent PyInstaller's binary dependency analysis from
creating symlinks to top-level application directory for shared libraries
discovered in the `torch/lib` directory during binary dependency analysis.

These symbolic links confuse certain `torch` builds about the location
of  `torch`, and prevent `torch/lib/libtorch_cuda_linalg.so` from being
(dynamically) loaded. The problematic builds are wheels provided by
https://download.pytorch.org/whl/torch for `torch` 1.13.x, 2.0.x, and
2.1.x (tested with 1.13.1+cu117, 2.0.1+cu117, and 2.1.2+cu118). Later
versions do not seem to be affected. The wheels provided on PyPI do
not seem to be affected either, regardless of the version.

However, these symlinks should be not necessary on linux in general,
so there should be no harm in suppressing them for all versions.
@rokm rokm merged commit 7d80e4b into pyinstaller:master Dec 3, 2024
2 checks passed
@rokm rokm deleted the linux-torch-cuda-linalg branch December 3, 2024 23:38
@jamesdbrock
Copy link

This works, thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

torch libtorch_cuda_linalg.so
3 participants