LaurentMazare / diffusers-rs

An implementation of the diffusers api in Rust
Apache License 2.0
521 stars 54 forks source link

PytorchStreamReader failed reading zip archive #55

Closed katopz closed 1 year ago

katopz commented 1 year ago

When trying

cargo run --example stable-diffusion --features clap -- --prompt "A rusty robot holding a fire torch."

I got

Error: Internal torch error: PytorchStreamReader failed reading zip archive: failed finding central directory
Exception raised from valid at /Users/runner/work/pytorch/pytorch/pytorch/caffe2/serialize/inline_container.cc:183 (most recent call first):
frame #0: c10::Error::Error(c10::SourceLocation, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >) + 98 (0x10818f992 in libc10.dylib)
frame #1: c10::detail::torchCheckFail(char const*, char const*, unsigned int, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 106 (0x10818e0aa in libc10.dylib)
frame #2: caffe2::serialize::PyTorchStreamReader::valid(char const*, char const*) + 128 (0x11806ddc0 in libtorch_cpu.dylib)
frame #3: caffe2::serialize::PyTorchStreamReader::init() + 315 (0x11806d1cb in libtorch_cpu.dylib)
frame #4: caffe2::serialize::PyTorchStreamReader::PyTorchStreamReader(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&) + 261 (0x11806cfe5 in libtorch_cpu.dylib)
frame #5: torch::jit::import_ir_module(std::__1::shared_ptr<torch::jit::CompilationUnit>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, c10::optional<c10::Device>, std::__1::unordered_map<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >, std::__1::hash<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::equal_to<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > >, std::__1::allocator<std::__1::pair<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > > > >&) + 519 (0x1194ed787 in libtorch_cpu.dylib)
frame #6: torch::jit::import_ir_module(std::__1::shared_ptr<torch::jit::CompilationUnit>, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, c10::optional<c10::Device>) + 69 (0x1194ed4c5 in libtorch_cpu.dylib)
frame #7: torch::jit::load(std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, c10::optional<c10::Device>) + 238 (0x1194ee5ce in libtorch_cpu.dylib)
frame #8: at_load_callback_with_device + 148 (0x10790e9f4 in stable-diffusion)
frame #9: tch::wrappers::tensor::Tensor::load_multi_with_device::h76a379da6fb3bc44 + 420 (0x10771b7c4 in stable-diffusion)
frame #10: tch::nn::var_store::VarStore::named_tensors::haabc631e8482797f + 246 (0x10771c826 in stable-diffusion)
frame #11: tch::nn::var_store::VarStore::load_internal::h57d18ea780681827 + 69 (0x10771bff5 in stable-diffusion)
frame #12: tch::nn::var_store::VarStore::load::h7744a82ce429d62d + 214 (0x10771cbd6 in stable-diffusion)
frame #13: diffusers::pipelines::stable_diffusion::StableDiffusionConfig::build_clip_transformer::h6195c2a8233c895b + 239 (0x10773b7af in stable-diffusion)
frame #14: stable_diffusion::run::h8a551142c83d2c48 + 4025 (0x107703c09 in stable-diffusion)
frame #15: stable_diffusion::main::hd0cfa2a2c29f23e0 + 121 (0x107705b19 in stable-diffusion)
frame #16: core::ops::function::FnOnce::call_once::h4135dd5f1b217b3c + 14 (0x1076f3ace in stable-diffusion)
frame #17: std::sys_common::backtrace::__rust_begin_short_backtrace::h8da8413ad3c77f72 + 17 (0x1077016f1 in stable-diffusion)
frame #18: std::rt::lang_start::_$u7b$$u7b$closure$u7d$$u7d$::h65c09f346b6d0be1 + 20 (0x1076e9584 in stable-diffusion)
frame #19: std::rt::lang_start_internal::haf0419567751b65f + 708 (0x107a8d744 in stable-diffusion)
frame #20: std::rt::lang_start::he551d2857570b3e6 + 55 (0x1076e9557 in stable-diffusion)
frame #21: main + 24 (0x10770a4b8 in stable-diffusion)
frame #22: start + 1 (0x7fff6abcacc9 in libdyld.dylib)

State

This is what my data folder look like and it run just fine for --sd-version v1-5 but get an above error 👆 for 2.1

bpe_simple_vocab_16e6.txt
clip_v2.1.ot
pytorch_model.ot
unet.ot
unet_v2.1.ot
vae.ot
vae_v2.1.ot

Not sure what files or flag I miss for 2.1?

LaurentMazare commented 1 year ago

That's odd, no flag should be required as 2.1 is the default if you do not pass the --sd-version flag. Googling this error message, a possible cause would be for the weight file to be corrupted, did you get clip_v2.1.ot from huggingface? Maybe you could check it's size and try downloading it again?

katopz commented 1 year ago

Aww, I feel stupid already! The clip_v2.1.ot is corrupted (file size not match) re-download did the trick! 😱 Many thanks!