diff --git a/torch/__init__.py b/torch/__init__.py index 2fd8005cf7792..d2d92e7aec999 100644 --- a/torch/__init__.py +++ b/torch/__init__.py @@ -66,9 +66,11 @@ 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') + 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 @@ -79,7 +81,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, 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(