Skip to content

Commit 7d2de40

Browse files
atalmandatumbox
andauthored
Fix windows python 3.8 required dlls not found (#6715)
* Fix windows python 3.8 * Update torchvision/extension.py Co-authored-by: Vasilis Vryniotis <[email protected]> * Update torchvision/extension.py Co-authored-by: Vasilis Vryniotis <[email protected]>
1 parent 61034d5 commit 7d2de40

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

torchvision/extension.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,18 @@ def _has_ops():
1616

1717

1818
try:
19+
# On Windows Python-3.8.x has `os.add_dll_directory` call,
20+
# which is called to configure dll search path.
21+
# To find cuda related dlls we need to make sure the
22+
# conda environment/bin path is configured Please take a look:
23+
# https://stackoverflow.com/questions/59330863/cant-import-dll-module-in-python
24+
if os.name == "nt" and sys.version_info >= (3, 8) and sys.version_info < (3, 9):
25+
env_path = os.environ["PATH"]
26+
path_arr = env_path.split(";")
27+
for path in path_arr:
28+
if os.path.exists(path):
29+
os.add_dll_directory(path) # type: ignore[attr-defined]
30+
1931
lib_path = _get_extension_path("_C")
2032
torch.ops.load_library(lib_path)
2133
_HAS_OPS = True

0 commit comments

Comments
 (0)