mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-07-14 03:16:59 +08:00
nit
This commit is contained in:
parent
10e08b0554
commit
73b26e5375
36
fix_torch.py
36
fix_torch.py
@ -5,20 +5,24 @@ import ctypes
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
|
|
||||||
torch_spec = importlib.util.find_spec("torch")
|
def fix_pytorch_libomp():
|
||||||
for folder in torch_spec.submodule_search_locations:
|
"""
|
||||||
lib_folder = os.path.join(folder, "lib")
|
Fix PyTorch libomp DLL issue on Windows by copying the correct DLL file if needed.
|
||||||
test_file = os.path.join(lib_folder, "fbgemm.dll")
|
"""
|
||||||
dest = os.path.join(lib_folder, "libomp140.x86_64.dll")
|
torch_spec = importlib.util.find_spec("torch")
|
||||||
if os.path.exists(dest):
|
for folder in torch_spec.submodule_search_locations:
|
||||||
break
|
lib_folder = os.path.join(folder, "lib")
|
||||||
|
test_file = os.path.join(lib_folder, "fbgemm.dll")
|
||||||
with open(test_file, 'rb') as f:
|
dest = os.path.join(lib_folder, "libomp140.x86_64.dll")
|
||||||
contents = f.read()
|
if os.path.exists(dest):
|
||||||
if b"libomp140.x86_64.dll" not in contents:
|
|
||||||
break
|
break
|
||||||
try:
|
|
||||||
mydll = ctypes.cdll.LoadLibrary(test_file)
|
with open(test_file, "rb") as f:
|
||||||
except FileNotFoundError as e:
|
contents = f.read()
|
||||||
logging.warning("Detected pytorch version with libomp issue, patching.")
|
if b"libomp140.x86_64.dll" not in contents:
|
||||||
shutil.copyfile(os.path.join(lib_folder, "libiomp5md.dll"), dest)
|
break
|
||||||
|
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"), dest)
|
||||||
|
4
main.py
4
main.py
@ -86,9 +86,9 @@ if __name__ == "__main__":
|
|||||||
import cuda_malloc
|
import cuda_malloc
|
||||||
|
|
||||||
if args.windows_standalone_build:
|
if args.windows_standalone_build:
|
||||||
# TODO: Convert fix_torch to a function.
|
|
||||||
try:
|
try:
|
||||||
import fix_torch # noqa: F401
|
from fix_torch import fix_pytorch_libomp
|
||||||
|
fix_pytorch_libomp()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user