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

Missing dlls when running executable without cargo #367

Closed
KarelPeeters opened this issue May 30, 2021 · 3 comments
Closed

Missing dlls when running executable without cargo #367

KarelPeeters opened this issue May 30, 2021 · 3 comments

Comments

@KarelPeeters
Copy link

First of all thanks for this crate, it's been very useful and pretty convenient to use so far!

I'm trying to run (and eventually distribute) an executable with tch as a dependency, it should use either cuda or cpu depending on availability.

Running it using cargo run works fine, although to get cuda working I had to add dummy_cuda_dependency() somewhere in my code as per #291. The problem is that if I try to run the exe myself I get a bunch of missing dll errors, specifically for torch_cuda_cpp.dll, c10.dll, torch_cuda_cpu and torch_cpu.dll. That makes sense, the dll files are in target\release\build\torch-sys-b2db2b9ea64c45bd\out\libtorch\libtorch\lib which is not on the search path.

What is the intended solution for this? For now I just manually copied the dll files into target\release, but that's a bit of a hack. Is there a better way to do this? And how do I set it up so I can actually ship this? Or should the automatic libtorch download be considered more as a small utility for developing with cargo but not something to actually use in the real world?

As a small related question, what does this paragraph mean?

Windows Specific Notes

As per the pytorch docs the Windows debug and release builds are not ABI-compatible. This could lead to some segfaults if the incorrect version of libtorch is used.

If I try to copy the dll files from target/debug/... next to the release executable it also works. Does that mean tch always downloads a release version of libtorch?

@LaurentMazare
Copy link
Owner

What is the intended solution for this? For now I just manually copied the dll files into target\release, but that's a bit of a hack. Is there a better way to do this? And how do I set it up so I can actually ship this? Or should the automatic libtorch download be considered more as a small utility for developing with cargo but not something to actually use in the real world?

I would indeed think of the automated libtorch download as a convenient way to get started up when developing with tch but not as a way to help deployment. For deployment, the best thing is probably to download "LibTorch" from the PyTorch website with the appropriate cuda/cpu setting, and install the shared objects from there at a discoverable system-wide location (on linux platforms, something like /usr/lib64 or when installing as a user setting LD_LIBRARY_PATH could help pointing at the right directory, not sure how that works on windows).

As a small related question, what does this paragraph mean?

Windows Specific Notes

As per the pytorch docs the Windows debug and release builds are not ABI-compatible. This could lead to some segfaults if the incorrect version of libtorch is used.

If I try to copy the dll files from target/debug/... next to the release executable it also works. Does that mean tch always downloads a release version of libtorch?

Exactly, tch always uses the release version of libtorch so in this case you are not running into any abi issue. However if for some reason you were to install manually the debug version you would end up with some missing symbol error at link time or something like this.

@LaurentMazare
Copy link
Owner

Closing this for now, feel free to re-open if further issues.

@KarelPeeters
Copy link
Author

Ah I'm sorry for not responding last time, manually installing libtorch turned out to be a good solution, thanks!

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

No branches or pull requests

2 participants