Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix windows python 3.8 required dlls not found (#6715) #6716

Merged
merged 1 commit into from Oct 10, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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