CompVis / stable-diffusion

A latent text-to-image diffusion model
https://ommer-lab.com/research/latent-diffusion-models/
Other
67.88k stars 10.12k forks source link

_pickle.UnpicklingError: invalid load key, 'A'. #432

Closed aleff-github closed 1 year ago

aleff-github commented 1 year ago

Computer: DELL XPS 15

OS: Ubuntu 22

Payload: python3 scripts/txt2img.py --prompt "boy with pink hat studying, in the style of Van Gogh" --plms --ckpt sd-v1-4.ckpt --skip_grid --n_samples 1 --H 384 --W 384 --seed 42

Env: ldm

Output:

/home/aleff/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/cuda/__init__.py:82: UserWarning: CUDA initialization: Unexpected error from cudaGetDeviceCount(). Did you run some cuda functions before calling NumCudaDevices() that might have already set an error? Error 803: system has unsupported display driver / cuda driver combination (Triggered internally at  /opt/conda/conda-bld/pytorch_1646755903507/work/c10/cuda/CUDAFunctions.cpp:112.)
  return torch._C._cuda_getDeviceCount() > 0
## sleping for a fiew seconds
Global seed set to 42
Loading model from sd-v1-4.ckpt
Traceback (most recent call last):
  File "scripts/txt2img.py", line 344, in <module>
    main()
  File "scripts/txt2img.py", line 240, in main
    model = load_model_from_config(config, f"{opt.ckpt}")
  File "scripts/txt2img.py", line 50, in load_model_from_config
    pl_sd = torch.load(ckpt, map_location="cpu")
  File "/home/aleff/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/serialization.py", line 713, in load
    return _legacy_load(opened_file, map_location, pickle_module, **pickle_load_args)
  File "/home/aleff/anaconda3/envs/ldm/lib/python3.8/site-packages/torch/serialization.py", line 920, in _legacy_load
    magic_number = pickle_module.load(f, **pickle_load_args)
_pickle.UnpicklingError: invalid load key, 'A'.

Note:

  1. ## sleping for a fiew seconds is not in the output, it is just a my note to indicate that in that point the output is sleeping
  2. The same output using python rather than python3
  3. Trying to change the payload removing or changing some parameters the situation doesn't change, the last one payload is the following python scripts/txt2img.py --prompt "boy with pink hat" --ckpt sd-v1-4.ckpt not working too with the same error
aleff-github commented 1 year ago

Solved following this steps:

  1. Go to this link https://huggingface.co/
  2. Signup and login
  3. Then go to this page https://huggingface.co/CompVis/stable-diffusion-v-1-4-original
  4. Click that you agree the terms (if you agree the terms, else you can't download it)
  5. Click to the link of sd-v1-4.ckpt (or click directly here)

I pushed this steps in the README.md file of this repository -> https://github.com/CompVis/stable-diffusion/pull/437