-
Notifications
You must be signed in to change notification settings - Fork 25.5k
Add path used by pip's build isolation procedure to DLL search #150013
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
Conversation
🔗 Helpful Links🧪 See artifacts and rendered test results at hud.pytorch.org/pr/150013
Note: Links to docs will display an error until the docs builds have been completed. ❌ 1 New FailureAs of commit 00a6eff with merge base 0d17029 ( NEW FAILURE - The following job has failed:
This comment was automatically generated by Dr. CI and updates every 15 minutes. |
This PR needs a
|
torch/__init__.py
Outdated
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.
Can we use shutil.which to find the path of MKL somehow?
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 don't think so, since the issue is that MKL is NOT in the PATH to begin with.
Looking at this code again, I think I made a copy/paste mistake though, this should read os.path.dirname(wheel.__file__), "..", ".."
: MKL gets installed in <tmp-pip-prefix>/Library/bin
, and the only way I found to get this <tmp-pip-prefix>
was to look where other build-time dependency such as wheel
are installed.
EDIT: no, this is fine, I got confused: I need to workaround this at build-time for my own packages (which import torch
in the setup.py, but here we are inside torch already … 😅
7bbd017
to
dc0ab5b
Compare
Looks like this PR hasn't been updated in a while so we're going to go ahead and mark this as |
Without this, trying to `import torch` in a downstream `setup.py` file would result in ``` The specified module could not be found. Error loading "C:\...\pip-build-env-himl3xh3\normal\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies." ``` This seems to be because pip does not use a full virtualenv for build isolation, instead creating directories and manually adding them to `sys.path`
dc0ab5b
to
00a6eff
Compare
@malfet @Skylion007 could this get a review? |
Re-opening a new PR after #131340 and #140535 where closed for being stale without a review.
Without this, trying to
import torch
in a downstreamsetup.py
file would result inThis seems to be because pip does not use a full virtualenv for build isolation, instead creating directories and manually adding them to
sys.path
. The same issue does not seem to apply when usingpython -m build
.To reproduce, you can create a directory with two files:
Then, trying to build a wheel with
pip install .
will give some output similar to:Torch is properly installed in
C:\Users\runneradmin\AppData\Local\Temp\pip-build-env-himl3xh3\normal\Lib\site-packages\torch\
and all the mkl libraries are inC:\Users\runneradmin\AppData\Local\Temp\pip-build-env-himl3xh3\normal\Library\bin
, but this directory is not covered by existing DLL paths.This is similar to #125109, and the fix is similar to #125684. Ping @atalman and @malfet since you fixed & reviewed the previous similar fix.