kohya-ss / kohya-ss/sd-scripts
ValueError:Cannot load xxxx from flux/vae because the following keys are missing
- Dominant language
- Python
- Stars
- 7.2k
- Forks
- 1.2k
- Avg merge
- 11m
- Merged PRs (30d)
- 2
Description
This is my error report:
`
Loading pipeline components...: 0%| | 0/3 [00:00
trainer.train(args)
File "/home/ma-user/sd-scripts/sd-scripts/train_network.py", line 236, in train
model_version, text_encoder, vae, unet = self.load_target_model(args, weight_dtype, accelerator)
File "/home/ma-user/sd-scripts/sd-scripts/train_network.py", line 103, in load_target_model
text_encoder, vae, unet, _ = train_util.load_target_model(args, weight_dtype, accelerator)
File "/home/ma-user/sd-scripts/sd-scripts/library/train_util.py", line 4387, in load_target_model
text_encoder, vae, unet, load_stable_diffusion_format = _load_target_model(
File "/home/ma-user/sd-scripts/sd-scripts/library/train_util.py", line 4349, in _load_target_model
accelerator device: cuda:2
pipe = StableDiffusionPipeline.from_pretrained(name_or_path, tokenizer=None, safety_checker=None)
File "/home/ma-user/anaconda3/envs/PyTorch-2.2.0/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
return fn(*args, **kwargs)
File "/home/ma-user/anaconda3/envs/PyTorch-2.2.0/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py", line 1271, in from_pretrained
loaded_sub_model = load_sub_model(
File "/home/ma-user/anaconda3/envs/PyTorch-2.2.0/lib/python3.10/site-packages/diffusers/pipelines/pipeline_utils.py", line 525, in load_sub_model
loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
File "/home/ma-user/anaconda3/envs/PyTorch-2.2.0/lib/python3.10/site-packages/huggingface_hub/utils/_validators.py", line 118, in _inner_fn
return fn(*args, **kwargs)
File "/home/ma-user/anaconda3/envs/PyTorch-2.2.0/lib/python3.10/site-packages/diffusers/models/modeling_utils.py", line 805, in from_pretrained
raise ValueError(
ValueError: Cannot load from /home_host/zj/flux/ai-modelscope/flux___1-dev/vae because the following keys are missing:
quant_conv.bias, post_quant_conv.weight, quant_conv.weight, post_quant_conv.bias.
Please make sure to pass `low_cpu_mem_usage=False` and `device_map=None` if you want to randomly initialize those weights or else make sure your checkpoint file is correct.
[ERROR] 2024-10-16-10:14:27 (PID:3362, Device:0, RankID:0) ERR99999 UNKNOWN application exception
`
Below is the model I used to train:
[https://huggingface.co/black-forest-labs/FLUX.1-dev/tree/main](url)
This is my executed command:
`
accelerate launch --num_cpu_threads_per_process 1 train_network.py \
--pretrained_model_name_or_path="/home_host/zj/flux/ai-modelscope/flux___1-dev" \
--dataset_config="/home/ma-user/sd-scripts/sd-scripts/train_first.toml" \
--output_dir="/home/ma-user/sd-scripts/sd-scripts/output" \
--output_name="output" \
--save_model_as=safetenpip isors \
--prior_loss_weight=1.0 \
--max_train_steps=3000 \
--learning_rate=1e-4 \
--optimizer_type="AdamW" \
--xformers \
--mixed_precision="fp16" \
--cache_latents \
--save_every_n_epochs=3000 \
--network_module=networks.lora
`
**How should I solve this problem? Thank you in advance for your answers**
Contributor guide
No contributing guide indexed for this repository
Research direction
Start with library/train_util.py at _load_target_model and load_target_model, then inspect the diffusers AutoencoderKL traceback for the missing VAE keys. Compare the FLUX.1-dev VAE files and configuration with the loader expectations, and reproduce using the supplied accelerate command; done when the target model loads without the missing-key ValueError.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, pytorch
- Domain
- machine-learning
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100