diff --git a/comfy/utils.py b/comfy/utils.py index 795350830..9931fe3b4 100644 --- a/comfy/utils.py +++ b/comfy/utils.py @@ -20,6 +20,8 @@ import torch import math import struct +import ctypes +import os import comfy.memory_management import safetensors.torch import numpy as np @@ -32,7 +34,6 @@ from einops import rearrange from comfy.cli_args import args import json import time -import mmap import threading import warnings @@ -82,12 +83,15 @@ _TYPES = { } def load_safetensors(ckpt): - f = open(ckpt, "rb", buffering=0) - mapping = mmap.mmap(f.fileno(), 0, access=mmap.ACCESS_READ) - mv = memoryview(mapping) + import comfy_aimdo.model_mmap - header_size = struct.unpack("