From 698f9474636d46a4c8dd29ef3762e1cef3a476bb Mon Sep 17 00:00:00 2001 From: peter Date: Fri, 1 Mar 2019 10:33:58 -0800 Subject: [PATCH] Revert #17191 and #17215 that no longer apply on Windows (#17567) Summary: They are previously merged to resolve #17051. However, since it was resolved by the upstream, and it was causing some issues like https://github.com/abjer/tsds/issues/8, I think it's time to revert these changes. Pull Request resolved: https://github.com/pytorch/pytorch/pull/17567 Differential Revision: D14265241 Pulled By: kostmo fbshipit-source-id: 7fa2b7dd4ebc5148681acb439cf82d983898694e --- caffe2/python/__init__.py | 22 ++-------------------- torch/__init__.py | 22 ++-------------------- 2 files changed, 4 insertions(+), 40 deletions(-) diff --git a/caffe2/python/__init__.py b/caffe2/python/__init__.py index 50e0c6c..b7f887b 100644 --- a/caffe2/python/__init__.py +++ b/caffe2/python/__init__.py @@ -15,23 +15,6 @@ caffe2_pb2.COMPILE_TIME_MAX_DEVICE_TYPES = caffe2_pb2.PROTO_COMPILE_TIME_MAX_DEV caffe2_pb2.ONLY_FOR_TEST = caffe2_pb2.PROTO_ONLY_FOR_TEST if platform.system() == 'Windows': - IS_CONDA = 'conda' in sys.version or 'Continuum' in sys.version or any([x.startswith('CONDA') for x in os.environ]) - - if IS_CONDA: - from ctypes import windll, c_wchar_p - from ctypes.wintypes import DWORD, HMODULE - - AddDllDirectory = windll.kernel32.AddDllDirectory - AddDllDirectory.restype = DWORD - AddDllDirectory.argtypes = [c_wchar_p] - - def add_extra_dll_dir(extra_dll_dir): - if os.path.isdir(extra_dll_dir): - os.environ['PATH'] = extra_dll_dir + os.pathsep + os.environ['PATH'] - - if IS_CONDA: - AddDllDirectory(extra_dll_dir) - # first get nvToolsExt PATH def get_nvToolsExt_path(): NVTOOLEXT_HOME = os.getenv('NVTOOLSEXT_PATH', 'C:\\Program Files\\NVIDIA Corporation\\NvToolsExt') @@ -45,8 +28,7 @@ if platform.system() == 'Windows': th_root = os.path.join(os.path.dirname(os.path.dirname(os.path.dirname(__file__))), 'torch') th_dll_path = os.path.join(th_root, 'lib') - dll_paths = [th_dll_path, py_dll_path, get_nvToolsExt_path()] + dll_paths = [th_dll_path, py_dll_path, get_nvToolsExt_path(), os.environ['PATH']] # then add the path to env - for p in dll_paths: - add_extra_dll_dir(p) + os.environ['PATH'] = ';'.join(dll_paths) diff --git a/torch/__init__.py b/torch/__init__.py index 8a48f00..a7503b9 100644 --- a/torch/__init__.py +++ b/torch/__init__.py @@ -44,23 +44,6 @@ except ImportError: pass if platform.system() == 'Windows': - IS_CONDA = 'conda' in sys.version or 'Continuum' in sys.version or any([x.startswith('CONDA') for x in os.environ]) - - if IS_CONDA: - from ctypes import windll, c_wchar_p - from ctypes.wintypes import DWORD, HMODULE - - AddDllDirectory = windll.kernel32.AddDllDirectory - AddDllDirectory.restype = DWORD - AddDllDirectory.argtypes = [c_wchar_p] - - def add_extra_dll_dir(extra_dll_dir): - if _dl_flags.path.isdir(extra_dll_dir): - _dl_flags.environ['PATH'] = extra_dll_dir + os.pathsep + _dl_flags.environ['PATH'] - - if IS_CONDA: - AddDllDirectory(extra_dll_dir) - # first get nvToolsExt PATH def get_nvToolsExt_path(): NVTOOLEXT_HOME = _dl_flags.getenv('NVTOOLSEXT_PATH', 'C:\\Program Files\\NVIDIA Corporation\\NvToolsExt') @@ -73,11 +56,10 @@ if platform.system() == 'Windows': py_dll_path = _dl_flags.path.join(_dl_flags.path.dirname(sys.executable), 'Library', 'bin') th_dll_path = _dl_flags.path.join(_dl_flags.path.dirname(__file__), 'lib') - dll_paths = [th_dll_path, py_dll_path, get_nvToolsExt_path()] + dll_paths = [th_dll_path, py_dll_path, get_nvToolsExt_path(), _dl_flags.environ['PATH']] # then add the path to env - for p in dll_paths: - add_extra_dll_dir(p) + _dl_flags.environ['PATH'] = ';'.join(dll_paths) else: # first check if the os package has the required flags -- 2.7.4