From 1b5e1b4dd4e173655c255a3c472b0a668d8c9414 Mon Sep 17 00:00:00 2001 From: Andrey Talman Date: Tue, 11 Oct 2022 12:41:55 -0400 Subject: [PATCH] Fix for windows and python 3.8 call to add_dll_directory (#6742) --- torchvision/extension.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/torchvision/extension.py b/torchvision/extension.py index 702e7e33b33..de5ea0c94d8 100644 --- a/torchvision/extension.py +++ b/torchvision/extension.py @@ -21,12 +21,16 @@ def _has_ops(): # To find cuda related dlls we need to make sure the # conda environment/bin path is configured Please take a look: # https://stackoverflow.com/questions/59330863/cant-import-dll-module-in-python + # Please note: if some path can't be added using add_dll_directory we simply ignore this path if os.name == "nt" and sys.version_info >= (3, 8) and sys.version_info < (3, 9): env_path = os.environ["PATH"] path_arr = env_path.split(";") for path in path_arr: if os.path.exists(path): - os.add_dll_directory(path) # type: ignore[attr-defined] + try: + os.add_dll_directory(path) # type: ignore[attr-defined] + except Exception: + pass lib_path = _get_extension_path("_C") torch.ops.load_library(lib_path)