From 5e92acaecd6800d8827fa3a05883ab4702db9c27 Mon Sep 17 00:00:00 2001 From: atalman Date: Tue, 7 May 2024 08:25:27 -0700 Subject: [PATCH 1/3] Add appdata path to dll windows dll --- torch/__init__.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/torch/__init__.py b/torch/__init__.py index 2fd8005cf7792..fbe352d392848 100644 --- a/torch/__init__.py +++ b/torch/__init__.py @@ -69,6 +69,7 @@ def _running_with_deploy(): pfiles_path = os.getenv('ProgramFiles', 'C:\\Program Files') py_dll_path = os.path.join(sys.exec_prefix, 'Library', 'bin') th_dll_path = os.path.join(os.path.dirname(__file__), 'lib') + appdata_dll_path = os.path.join(os.getenv('APPDATA'), 'Python', 'Library', 'bin') # When users create a virtualenv that inherits the base environment, # we will need to add the corresponding library directory into @@ -79,7 +80,7 @@ def _running_with_deploy(): else: base_py_dll_path = '' - dll_paths = list(filter(os.path.exists, [th_dll_path, py_dll_path, base_py_dll_path])) + dll_paths = list(filter(os.path.exists, [th_dll_path, py_dll_path, base_py_dll_path, appdata_dll_path])) if all(not os.path.exists(os.path.join(p, 'nvToolsExt64_1.dll')) for p in dll_paths): nvtoolsext_dll_path = os.path.join( From 1a3cb8ef068e826681b6f296ba04dc7fe245c7a8 Mon Sep 17 00:00:00 2001 From: Nikita Shulga <2453524+malfet@users.noreply.github.com> Date: Tue, 7 May 2024 10:05:42 -0700 Subject: [PATCH 2/3] Apply suggestions from code review --- torch/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/torch/__init__.py b/torch/__init__.py index fbe352d392848..2970d6998f2de 100644 --- a/torch/__init__.py +++ b/torch/__init__.py @@ -69,7 +69,7 @@ def _running_with_deploy(): pfiles_path = os.getenv('ProgramFiles', 'C:\\Program Files') py_dll_path = os.path.join(sys.exec_prefix, 'Library', 'bin') th_dll_path = os.path.join(os.path.dirname(__file__), 'lib') - appdata_dll_path = os.path.join(os.getenv('APPDATA'), 'Python', 'Library', 'bin') + usebase_path = os.path.join(sysconfig.get_config_var("userbase"), 'Library', 'bin') # When users create a virtualenv that inherits the base environment, # we will need to add the corresponding library directory into @@ -80,7 +80,7 @@ def _running_with_deploy(): else: base_py_dll_path = '' - dll_paths = list(filter(os.path.exists, [th_dll_path, py_dll_path, base_py_dll_path, appdata_dll_path])) + dll_paths = list(filter(os.path.exists, [th_dll_path, py_dll_path, base_py_dll_path, usebase_path])) if all(not os.path.exists(os.path.join(p, 'nvToolsExt64_1.dll')) for p in dll_paths): nvtoolsext_dll_path = os.path.join( From 202f1549bf6bd59eddfd6a4220745b443be96154 Mon Sep 17 00:00:00 2001 From: Nikita Shulga <2453524+malfet@users.noreply.github.com> Date: Tue, 7 May 2024 10:07:11 -0700 Subject: [PATCH 3/3] Update __init__.py --- torch/__init__.py | 1 + 1 file changed, 1 insertion(+) diff --git a/torch/__init__.py b/torch/__init__.py index 2970d6998f2de..d2d92e7aec999 100644 --- a/torch/__init__.py +++ b/torch/__init__.py @@ -66,6 +66,7 @@ def _running_with_deploy(): ################################################################################ if sys.platform == 'win32': + import sysconfig pfiles_path = os.getenv('ProgramFiles', 'C:\\Program Files') py_dll_path = os.path.join(sys.exec_prefix, 'Library', 'bin') th_dll_path = os.path.join(os.path.dirname(__file__), 'lib')