Skip to content

Commit 2b5da3b

Browse files
authored
dynamic_vram: silence pytorch buffer warning (#12210)
This is log clutter and concerning to users. Its a false alarm.
1 parent 794d05b commit 2b5da3b

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

comfy/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import json
3333
import time
3434
import mmap
35+
import warnings
3536

3637
MMAP_TORCH_FILES = args.mmap_torch_files
3738
DISABLE_MMAP = args.disable_mmap
@@ -85,7 +86,10 @@ def load_safetensors(ckpt):
8586
header_size = struct.unpack("<Q", mapping[:8])[0]
8687
header = json.loads(mapping[8:8+header_size].decode("utf-8"))
8788

88-
data_area = torch.frombuffer(mapping, dtype=torch.uint8)[8 + header_size:]
89+
with warnings.catch_warnings():
90+
#We are working with read-only RAM by design
91+
warnings.filterwarnings("ignore", message="The given buffer is not writable")
92+
data_area = torch.frombuffer(mapping, dtype=torch.uint8)[8 + header_size:]
8993

9094
sd = {}
9195
for name, info in header.items():

0 commit comments

Comments
 (0)