Skip to content

Commit

Permalink
Fix windows python 3.8 required dlls not found (#6715) (#6716)
Browse files Browse the repository at this point in the history
* Fix windows python 3.8

* Update torchvision/extension.py

Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>

* Update torchvision/extension.py

Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>

Co-authored-by: Vasilis Vryniotis <datumbox@users.noreply.github.com>
  • Loading branch information
atalman and datumbox committed Oct 10, 2022
1 parent 5ff802b commit 95bef27
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions torchvision/extension.py
Expand Up @@ -16,6 +16,18 @@ def _has_ops():


try:
# 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:
# 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) # type: ignore[attr-defined]

lib_path = _get_extension_path("_C")
torch.ops.load_library(lib_path)
_HAS_OPS = True
Expand Down

0 comments on commit 95bef27

Please sign in to comment.