8000 Add userbase library dir to windows dll search path (#125684) · pytorch/pytorch@07ec09d · GitHub
[go: up one dir, main page]

Skip to content

Commit 07ec09d

Browse files
atalmanpytorchbot
authored andcommitted
Add userbase library dir to windows dll search path (#125684)
Fixes #125109 which is a regression introduced by pytorch/builder#1467 that adds dynamic dependency to mkl, which if installed in the user-dir is placed into `sysconfig.sysconfig.get_config_var("userbase") / "Library" / "bin"` Fix this one, but adding `userbase` folder to the DLL search path Testing before this fix: ``` Python 3.12.3 (tags/v3.12.3:f6650f9, Apr 9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import torch Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Users\Administrator\AppData\Roaming\Python\Python312\site-packages\torch\__init__.py", line 141, in <module> raise err OSError: [WinError 126] The specified module could not be found. Error loading "C:\Users\Administrator\AppData\Roaming\Python\Python312\site-packages\torch\lib\shm.dll" or one of its dependencies. >>> exit() ``` After: ``` c:\Program Files\Python312>python Python 3.12.3 (tags/v3.12.3:f6650f9, Apr 9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> import torch >>> exit() ``` Co-authored-by: Nikita Shulga <2453524+malfet@users.noreply.github.com> Pull Request resolved: #125684 Approved by: https://github.com/malfet (cherry picked from commit fdfef75)
1 parent 2e165ec commit 07ec09d

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

torch/__init__.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,11 @@ def _running_with_deploy():
6565
################################################################################
6666

6767
if sys.platform == 'win32':
68+
import sysconfig
6869
pfiles_path = os.getenv('ProgramFiles', 'C:\\Program Files')
6970
py_dll_path = os.path.join(sys.exec_prefix, 'Library', 'bin')
7071
th_dll_path = os.path.join(os.path.dirname(__file__), 'lib')
72+
usebase_path = os.path.join(sysconfig.get_config_var("userbase"), 'Library', 'bin')
7173

7274
# When users create a virtualenv that inherits the base environment,
7375
# we will need to add the corresponding library directory into
@@ -78,7 +80,7 @@ def _running_with_deploy():
7880
else:
7981
base_py_dll_path = ''
8082

81-
dll_paths = list(filter(os.path.exists, [th_dll_path, py_dll_path, base_py_dll_path]))
83+
dll_paths = list(filter(os.path.exists, [th_dll_path, py_dll_path, base_py_dll_path, usebase_path]))
8284

8385
if all(not os.path.exists(os.path.join(p, 'nvToolsExt64_1.dll')) for p in dll_paths):
8486
nvtoolsext_dll_path = os.path.join(

0 commit comments

Comments
 (0)
0