From 4e851e2cfa4fa5b6b3c3243fabae9354adf6f33e Mon Sep 17 00:00:00 2001 From: doctorpangloss <@hiddenswitch.com> Date: Tue, 30 Jul 2024 11:17:25 -0700 Subject: [PATCH] Fix torch 2.4.0 fix --- comfy/cmd/main_pre.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/comfy/cmd/main_pre.py b/comfy/cmd/main_pre.py index 4c578fdd9..3808152c3 100644 --- a/comfy/cmd/main_pre.py +++ b/comfy/cmd/main_pre.py @@ -59,19 +59,22 @@ def _fix_pytorch_240(): if os.path.exists(dest): break - with open(test_file, 'rb') as f: - contents = f.read() - # todo: dubious - if b"libomp140.x86_64.dll" not in contents: - break try: - _ = ctypes.cdll.LoadLibrary(test_file) - except FileNotFoundError: - logging.warning("Detected pytorch version with libomp issue, trying to patch") + with open(test_file, 'rb') as f: + contents = f.read() + # todo: dubious + if b"libomp140.x86_64.dll" not in contents: + break try: - shutil.copyfile(os.path.join(lib_folder, "libiomp5md.dll"), dest) - except Exception as exc_info: - logging.error("While trying to patch a fix for torch 2.4.0, an error occurred, which means this is unlikely to work", exc_info=exc_info) + _ = ctypes.cdll.LoadLibrary(test_file) + except FileNotFoundError: + logging.warning("Detected pytorch version with libomp issue, trying to patch") + try: + shutil.copyfile(os.path.join(lib_folder, "libiomp5md.dll"), dest) + except Exception as exc_info: + logging.error("While trying to patch a fix for torch 2.4.0, an error occurred, which means this is unlikely to work", exc_info=exc_info) + except: + pass def _create_tracer():