comfyanonymous / ComfyUI

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface.
https://www.comfy.org/
GNU General Public License v3.0
50.64k stars 5.32k forks source link

Stable Diffusion 3 - SD3 Not loading #3693

Closed LordAlex2015 closed 3 months ago

LordAlex2015 commented 3 months ago

When I try to execute a prompt with the new SD3 model (The 10 Gig one) (on the default workflow): I get this error:

!!! Exception during processing!!! Error while deserializing header: InvalidHeaderDeserialization
Traceback (most recent call last):
  File "I:\Ai\ComfyUI\execution.py", line 151, in recursive_execute
    output_data, output_ui = get_output_data(obj, input_data_all)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "I:\Ai\ComfyUI\execution.py", line 81, in get_output_data
    return_values = map_node_over_list(obj, input_data_all, obj.FUNCTION, allow_interrupt=True)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "I:\Ai\ComfyUI\execution.py", line 74, in map_node_over_list
    results.append(getattr(obj, func)(**slice_dict(input_data_all, i)))
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "I:\Ai\ComfyUI\nodes.py", line 516, in load_checkpoint
    out = comfy.sd.load_checkpoint_guess_config(ckpt_path, output_vae=True, output_clip=True, embedding_directory=folder_paths.get_folder_paths("embeddings"))
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "I:\Ai\ComfyUI\comfy\sd.py", line 464, in load_checkpoint_guess_config
    sd = comfy.utils.load_torch_file(ckpt_path)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "I:\Ai\ComfyUI\comfy\utils.py", line 14, in load_torch_file
    sd = safetensors.torch.load_file(ckpt, device=device.type)
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "I:\Ai\ComfyUI\env\Lib\site-packages\safetensors\torch.py", line 309, in load_file
    with safe_open(filename, framework="pt", device=device) as f:
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
safetensors_rust.SafetensorError: Error while deserializing header: InvalidHeaderDeserialization

Can someone help me fix it?

RedDeltas commented 3 months ago

I have this exact same error

I'm on ComfyUI: 218[605e64](2024-06-12) Using a RTX 4090 on RunPod using the runpod/stable-diffusion:fast-stable-diffusion-2.4.0 template

ltdrdata commented 3 months ago

Your model file is invalid file.

comfyanonymous commented 3 months ago

You either need to update pytorch to 2.2 or higher or your model is corrupt.

RedDeltas commented 3 months ago

I don't think my model is corrupt, my SHA256 is 92db4295e9c9ab8401ef60566d975656a35b0bd0f6d9ce0d083725171f7b3174 which matches the one on the file page here: https://huggingface.co/stabilityai/stable-diffusion-3-medium/blob/main/sd3_medium_incl_clips_t5xxlfp8.safetensors

RedDeltas commented 3 months ago

It could be my torch version, I'm using torch==2.0.1+cu118

RedDeltas commented 3 months ago

OK I've tried the following versions but I still have the same issue

comfyanonymous commented 3 months ago

oh, you also need to update the safetensors library.

RedDeltas commented 3 months ago

Updating safetensors made it work, thank you @comfyanonymous ♥️

oxysoft commented 3 months ago

Updating to 2.3.1 worked for me.

For those who have this issue, here is a summary of this thread

1. Check the sha-256

Verify that your downloads are not broken. Open PowerShell prompt in your model directories and compare the SHA-256 on each file

cd D:\ai-models
Get-FileHash .\Stable-diffusion\sd3_medium.safetensors
Get-FileHash .\clip\clip_g.safetensors
Get-FileHash .\clip\clip_l.safetensors
Get-FileHash .\clip\t5xxl_fp8_e4m3fn.safetensors

to the ones on HuggingFace by clicking on them.

2. Update torch to 2.3.1

cd D:\Projects\ComfyUI_windows_portable
.\python_embeded\python.exe -m pip install torch>=2.3.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

3. Update safetensors

cd D:\Projects\ComfyUI_windows_portable
.\python_embeded\python.exe -m pip install safetensors --upgrade
LordAlex2015 commented 3 months ago

Yeah, updating torch and safetensors worked for me

naghtan-droid commented 3 months ago

same here... cant load it... cant see it.... strange..

raidduelist commented 1 month ago

Same It doesn't load Failed product I was so exited to try Now i am disappointed

leohu1 commented 4 weeks ago

Updating to 2.3.1 worked for me.

For those who have this issue, here is a summary of this thread

1. Check the sha-256

Verify that your downloads are not broken. Open PowerShell prompt in your model directories and compare the SHA-256 on each file

cd D:\ai-models
Get-FileHash .\Stable-diffusion\sd3_medium.safetensors
Get-FileHash .\clip\clip_g.safetensors
Get-FileHash .\clip\clip_l.safetensors
Get-FileHash .\clip\t5xxl_fp8_e4m3fn.safetensors

to the ones on HuggingFace by clicking on them.

2. Update torch to 2.3.1

cd D:\Projects\ComfyUI_windows_portable
.\python_embeded\python.exe -m pip install torch>=2.3.1 torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118

3. Update safetensors

cd D:\Projects\ComfyUI_windows_portable
.\python_embeded\python.exe -m pip install safetensors --upgrade

Updating works for me.