Need advice: PytorchStreamReader failed reading zip archive
Hello!I’m new to this and I’m trying to get SD running on my local Windows 10 machine in an Anaconda Powershell Prompt. I’ve been sorting out dependencies but I’ve run into an error I can’t figure out:(ldm) PS C:\Users\dev_w\Documents\GitHub\stable-diffusion> python scripts/txt2img.py --prompt "prompt in space" --plms --ckpt sd-v1-4.ckpt --skip_grid --n_samples 1
Global seed set to 42
Loading model from sd-v1-4.ckpt
Traceback (most recent call last):
  File "scripts/txt2img.py", line 352, in <module>
    main()
  File "scripts/txt2img.py", line 246, in main
    model = load_model_from_config(config, f"{opt.ckpt}")
  File "scripts/txt2img.py", line 51, in load_model_from_config
    pl_sd = torch.load(ckpt, map_location="cpu")
  File "C:\Users\dev_w\miniconda3\envs\ldm\lib\site-packages\torch\serialization.py", line 705, in load
    with _open_zipfile_reader(opened_file) as opened_zipfile:
  File "C:\Users\dev_w\miniconda3\envs\ldm\lib\site-packages\torch\serialization.py", line 243, in __init__
    super(_open_zipfile_reader, self).__init__(torch._C.PyTorchFileReader(name_or_buffer))
RuntimeError: PytorchStreamReader failed reading zip archive: invalid header or archive is corruptedI’m not sure what zip file it’s trying to read. I re-downloadedsd-v1-4.ckptbut it didn’t help. Here’s the output fromtransformers-cli.exe env:(ldm) PS C:\Users\dev_w\Documents\GitHub\stable-diffusion> transformers-cli.exe env
Traceback (most recent call last):
  File "c:\users\dev_w\miniconda3\envs\ldm\lib\runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "c:\users\dev_w\miniconda3\envs\ldm\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "C:\Users\dev_w\miniconda3\envs\ldm\Scripts\transformers-cli.exe\__main__.py", line 4, in <module>
  File "c:\users\dev_w\miniconda3\envs\ldm\lib\site-packages\transformers\commands\transformers_cli.py", line 26, in <module>
    from .user import UserCommands
  File "c:\users\dev_w\miniconda3\envs\ldm\lib\site-packages\transformers\commands\user.py", line 20, in <module>
    from huggingface_hub.REDACTED_TOKEN import HfFolder, create_repo, login, logout, whoami
ImportError: cannot import name 'login' from 'huggingface_hub.REDACTED_TOKEN' (c:\users\dev_w\miniconda3\envs\ldm\lib\site-packages\huggingface_hub\REDACTED_TOKEN.py)Any help is appreciated!
2023-01-11T15:02:35Z
Did you manage to solve this? have same problem too
2023-01-11T16:33:58Z
No, not yet. I haven’t been able to get anyone to respond to me.
2023-03-24T16:33:55Z
I fixed a similar issue for myself recently by doing the following:Open python file @File "C:\Users\dev_w\miniconda3\envs\ldm\lib\site-packages\torch\serialization.py", line 243, in __init__Scroll to line 243, mine looked like this:class _open_zipfile_reader(_opener):
    def __init__(self, name_or_buffer) -> None:
        super().__init__(torch._C.PyTorchFileReader(name_or_buffer))Added some prints to find out which file wasn’t loading:class _open_zipfile_reader(_opener):
    def __init__(self, name_or_buffer) -> None:
        print('*******************************************')
        print(name_or_buffer)
        print('*******************************************')
        super().__init__(torch._C.PyTorchFileReader(name_or_buffer))Re run the command and I see the filename in the output (yours will be different since we are playing with different models):*******************************************
<_io.BufferedReader name='/home/user/.cache/audioldm/audioldm-s-full.ckpt'>
*******************************************This file audioldm-s-full.ckpt (the model file) was corrupt, so I deleted it and the next time I ran the command, the model re-downloaded.Hope this helps!
2023-04-28T14:22:25Z
Oh my god, You are a savior. Thanks a lot!!!
2024-08-16T07:24:54Z
nice! It solved the problem very well
2025-01-24T17:38:42Z
I deleted the incompletely downloaded model several times and the download continued to fail, but I noticed the.cachefile path as well as the url within the error message (traceback).  So I was able to use my browser to visit the download url (https://download.pytorch.org/torchaudio/models/wav2vec2_fairseq_base_ls960_asr_ls960.pth) and the download went fine.  I guess the pytorch package doesn’t do large file downloading over flaky network connections very well, but a good browser like Firefox had a download manager that’s a little smarter about error correction and recovery.