From 5769c91e4f6e6d5d106f75260461a604eb5f82cb Mon Sep 17 00:00:00 2001 From: atalman Date: Thu, 6 Oct 2022 06:56:24 -0700 Subject: [PATCH 1/3] Fix windows python 3.8 --- torchvision/extension.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/torchvision/extension.py b/torchvision/extension.py index 3bad8351b23..59ad0267742 100644 --- a/torchvision/extension.py +++ b/torchvision/extension.py @@ -16,6 +16,18 @@ def _has_ops(): try: + # On Windows Python-3.8+ has `os.add_dll_directory` call, + # which is called to configure dll search path. + # 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 + 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) + lib_path = _get_extension_path("_C") torch.ops.load_library(lib_path) _HAS_OPS = True From f7fed657be1eb19e0b4e992ef06dca9813fcc387 Mon Sep 17 00:00:00 2001 From: Andrey Talman Date: Thu, 6 Oct 2022 10:19:39 -0400 Subject: [PATCH 2/3] Update torchvision/extension.py Co-authored-by: Vasilis Vryniotis --- torchvision/extension.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/extension.py b/torchvision/extension.py index 59ad0267742..d60ba259d47 100644 --- a/torchvision/extension.py +++ b/torchvision/extension.py @@ -26,7 +26,7 @@ def _has_ops(): path_arr = env_path.split(";") for path in path_arr: if os.path.exists(path): - os.add_dll_directory(path) + os.add_dll_directory(path) # type: ignore[attr-defined] lib_path = _get_extension_path("_C") torch.ops.load_library(lib_path) From e4e3a0d077db7ccbd37c639dfc003b63dc0bded8 Mon Sep 17 00:00:00 2001 From: Andrey Talman Date: Thu, 6 Oct 2022 10:29:03 -0400 Subject: [PATCH 3/3] Update torchvision/extension.py --- torchvision/extension.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/torchvision/extension.py b/torchvision/extension.py index d60ba259d47..702e7e33b33 100644 --- a/torchvision/extension.py +++ b/torchvision/extension.py @@ -16,7 +16,7 @@ def _has_ops(): try: - # On Windows Python-3.8+ has `os.add_dll_directory` call, + # On Windows Python-3.8.x has `os.add_dll_directory` call, # which is called to configure dll search path. # To find cuda related dlls we need to make sure the # conda environment/bin path is configured Please take a look: