-
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
[Windows] Workaround for loading bundled DLLs #4893
Conversation
💊 CI failures summary and remediationsAs of commit cbf01c9 (more details on the Dr. CI page):
2 failures not recognized by patterns:
This comment was automatically generated by Dr. CI (expand for details).Please report bugs/suggestions to the (internal) Dr. CI Users group. |
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.
I can't comment on the actual content. One minor syntax error and a few questions inline.
4ed6dd3
to
2ee1bd7
Compare
It seems that these changes were also introduced back in PR #2811, do we know why they were removed? |
Hmm, that's a very good point. Looks like it was accidentally deleted by #4080 |
2ee1bd7
to
155bd1b
Compare
Thanks for the ping, and sorry for the trouble. Prior to #4080 we had 3 different registration mechanisms - one for extensions.py, one for image, and one for video. I unified them into a single one - it wasn't clear why each of them were different (no comments, no link to related issues), so I picked the simplest one that seemed to work: the one from |
c0ab563
to
cbf01c9
Compare
cbf01c9
to
2d8c032
Compare
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 a lot Nikita, and sorry for the delay in getting back on this.
I have one high-level comment, otherwise the PR is good to merge.
Moved |
torchvision/io/image.py
Outdated
import ctypes | ||
import os | ||
import sys |
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.
nit: you probably need to move those imports to extension.py
now
6741c31
to
d93ac2c
Compare
Python-3.8+ adds `add_dll_directory` call, see https://docs.python.org/3/whatsnew/3.8.html#ctypes Simulate this behaviour on older versions of Python runtime by calling `LoadLibraryExW` with the appropriate flags Fixes #4787
Get rid of `pass`, import `os`, `sys` and `warnnings` globally, fix `global()`->`globals()` typo
d93ac2c
to
52a6e14
Compare
Hey @malfet! You merged this PR, but no labels were added. The list of valid labels is available at https://github.com/pytorch/vision/blob/main/.github/process_commit.py |
* [Windows] Workaround for loading bundled DLLs Python-3.8+ adds `add_dll_directory` call, see https://docs.python.org/3/whatsnew/3.8.html#ctypes Simulate this behaviour on older versions of Python runtime by calling `LoadLibraryExW` with the appropriate flags Fixes #4787
Summary: * [Windows] Workaround for loading bundled DLLs Python-3.8+ adds `add_dll_directory` call, see https://docs.python.org/3/whatsnew/3.8.html#ctypes Simulate this behaviour on older versions of Python runtime by calling `LoadLibraryExW` with the appropriate flags Fixes #4787 Reviewed By: prabhat00155 Differential Revision: D33253476 fbshipit-source-id: bc462bf1c3b161646b258abc495c46f32aa1b459
pass | ||
_load_library("image") | ||
except (ImportError, OSError) as e: | ||
warn(f"Failed to load image Python extension: {e}") |
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.
Is there a reason that this was changed from pass
to warn
? When running pytest
on my project, I see warnings like:
../.spack/.spack-env/view/lib/python3.9/site-packages/torchvision/io/image.py:11
/Users/Adam/.spack/.spack-env/view/lib/python3.9/site-packages/torchvision/io/image.py:11: UserWarning: Failed to load image Python extension:
warn(f"Failed to load image Python extension: {e}")
It's unclear if this is a serious bug in my installation that I should fix, or something I can safely ignore. FWIW, I'm using the pillow-SIMD backend.
Python-3.8+ adds
add_dll_directory
call, see https://docs.python.org/3/whatsnew/3.8.html#ctypesSimulate this behaviour on older versions of Python runtime by calling
LoadLibraryExW
with the appropriate flagsFixes #4787
cc @peterjc123 @nbcsm @guyang3532 @maxluk @gunandrose4u @mszhanyi