Skip to content

Commit 531a2ea

Browse files
authored
Fix for windows and python 3.8 call to add_dll_directory (#6742) (#6743)
1 parent 95bef27 commit 531a2ea

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

torchvision/extension.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,16 @@ def _has_ops():
2121
# To find cuda related dlls we need to make sure the
2222
# conda environment/bin path is configured Please take a look:
2323
# https://stackoverflow.com/questions/59330863/cant-import-dll-module-in-python
24+
# Please note: if some path can't be added using add_dll_directory we simply ignore this path
2425
if os.name == "nt" and sys.version_info >= (3, 8) and sys.version_info < (3, 9):
2526
env_path = os.environ["PATH"]
2627
path_arr = env_path.split(";")
2728
for path in path_arr:
2829
if os.path.exists(path):
29-
os.add_dll_directory(path) # type: ignore[attr-defined]
30+
try:
31+
os.add_dll_directory(path) # type: ignore[attr-defined]
32+
except Exception:
33+
pass
3034

3135
lib_path = _get_extension_path("_C")
3236
torch.ops.load_library(lib_path)

0 commit comments

Comments
 (0)