-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Fix external DLL loading on wheels #2811
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the PR!
I'm not very comfortable with the current solution.
Would there be a way to fix Windows without having to do this PATH manipulation at import time?
For reference, we identified in #2775 that the Windows pip package for torchvision are still not loading image.dll
correctly, and this PR is a tentative fix for it.
Codecov Report
@@ Coverage Diff @@
## master #2811 +/- ##
==========================================
- Coverage 73.33% 73.26% -0.08%
==========================================
Files 99 99
Lines 8730 8778 +48
Branches 1374 1387 +13
==========================================
+ Hits 6402 6431 +29
- Misses 1909 1920 +11
- Partials 419 427 +8
Continue to review full report at Codecov.
|
It seems that this solution is damaging also the binary imports of other libraries, such as Scipy |
@peterjc123 could you help review this PR? For context, we identified in #2775 that the Windows pip package for torchvision are still not loading image.dll correctly, and this PR is a tentative fix for it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. BTW, it would be better to refactor the code to eliminate duplicates.
No, unlike unix platforms, Windows doesn't have an alternative for RPATH for native executables. |
Thanks @andfoy and @peterjc123 , I'm merging this to unblock and do some testings. Also, one thing that I would like to point out is that there is a non-symmetric inclusion here, where we add the path to the DLLs in |
* Fix external DLL loading on wheels * Use SetDefaultDllDirectoriess and AddDllDirectory * Add previous paths * Trigger debug * Do not call SetDefaultDllDirectories. * Do not call loadlibrary if the extensions were not compiled * Fix lint issues
* Fix external DLL loading on wheels * Use SetDefaultDllDirectoriess and AddDllDirectory * Add previous paths * Trigger debug * Do not call SetDefaultDllDirectories. * Do not call loadlibrary if the extensions were not compiled * Fix lint issues
* Fix external DLL loading on wheels * Use SetDefaultDllDirectoriess and AddDllDirectory * Add previous paths * Trigger debug * Do not call SetDefaultDllDirectories. * Do not call loadlibrary if the extensions were not compiled * Fix lint issues
This PR registers the path of the main torchvision library via
AddDllDirectory
on Python < 3.7 andos.add_dll_directory
on Python >= 3.8. The extensions are preloaded usingLoadLibraryExW
to circunvent the limitation imposed byAddDllDirectory
without callingSetDefaultDllDirectories