Skip to content

Commit

Permalink
Add code to fix issues with new pytorch version on the standalone.
Browse files Browse the repository at this point in the history
  • Loading branch information
comfyanonymous committed Jul 24, 2024
1 parent 10b43ce commit 19944ad
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
16 changes: 16 additions & 0 deletions fix_torch.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import importlib.util
import shutil
import os
import ctypes
import logging


torch_spec = importlib.util.find_spec("torch")
for folder in torch_spec.submodule_search_locations:
lib_folder = os.path.join(folder, "lib")
test_file = os.path.join(lib_folder, "fbgemm.dll")
try:
mydll = ctypes.cdll.LoadLibrary(test_file)
except FileNotFoundError as e:
logging.warning("Detected pytorch version with libomp issue, patching.")
shutil.copyfile(os.path.join(lib_folder, "libiomp5md.dll"), os.path.join(lib_folder, "libomp140.x86_64.dll"))
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ def execute_script(script_path):

import cuda_malloc

if args.windows_standalone_build:
try:
import fix_torch
except:
pass

import comfy.utils
import yaml

Expand Down

0 comments on commit 19944ad

Please sign in to comment.