kohya-ss / sd-scripts

Apache License 2.0
5.31k stars 880 forks source link

Lycoris issue #1662

Open TeKett opened 1 month ago

TeKett commented 1 month ago

So i tried lycoris with xl and got this.

Traceback (most recent call last):
  File "C:\Train\kohya\sd-scripts\sdxl_train_network.py", line 185, in <module>
    trainer.train(args)
  File "C:\Train\kohya\sd-scripts\train_network.py", line 299, in train
    network = network_module.create_network(
  File "C:\Train\kohya\venv\lib\site-packages\lycoris\kohya\__init__.py", line 148, in create_network
    delattr(type(network), "apply_max_norm_regularization")
AttributeError: apply_max_norm_regularization
Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Train\kohya\venv\Scripts\accelerate.EXE\__main__.py", line 7, in <module>
  File "C:\Train\kohya\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 47, in main
    args.func(args)
  File "C:\Train\kohya\venv\lib\site-packages\accelerate\commands\launch.py", line 1017, in launch_command
    simple_launcher(args)
  File "C:\Train\kohya\venv\lib\site-packages\accelerate\commands\launch.py", line 637, in simple_launcher
    raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
subprocess.CalledProcessError: Command '['C:\\Train\\kohya\\venv\\Scripts\\python.exe', 'C:/Train/kohya/sd-scripts/sdxl_train_network.py', '--config_file', 'C:\\Train\\train model/config_lora-20241002-131613.toml']' returned non-zero exit status 1.

A similar issue was posted on lycoris page half a year ago, and the lycoris dev said that it was outdated, and made v3. Kohya/sdscripts still uses v2.2 However, updating to v3 creates more errors.

Traceback (most recent call last):
  File "C:\Train\kohya\sd-scripts\sdxl_train_network.py", line 185, in <module>
    trainer.train(args)
  File "C:\Train\kohya\sd-scripts\train_network.py", line 845, in train
    text_encoder_conds = self.get_text_cond(
  File "C:\Train\kohya\sd-scripts\sdxl_train_network.py", line 115, in get_text_cond
    encoder_hidden_states1, encoder_hidden_states2, pool2 = train_util.get_hidden_states_sdxl(
  File "C:\Train\kohya\sd-scripts\library\train_util.py", line 4522, in get_hidden_states_sdxl
    enc_out = text_encoder1(input_ids1, output_hidden_states=True, return_dict=True)
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\accelerate\utils\operations.py", line 680, in forward
    return model_forward(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\accelerate\utils\operations.py", line 668, in __call__
    return convert_to_fp32(self.model_forward(*args, **kwargs))
  File "C:\Train\kohya\venv\lib\site-packages\torch\amp\autocast_mode.py", line 16, in decorate_autocast
    return func(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 806, in forward
    return self.text_model(
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 711, in forward
    encoder_outputs = self.encoder(
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 630, in forward
    layer_outputs = self._gradient_checkpointing_func(
  File "C:\Train\kohya\venv\lib\site-packages\torch\_compile.py", line 24, in inner
    return torch._dynamo.disable(fn, recursive)(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\torch\_dynamo\eval_frame.py", line 328, in _fn
    return fn(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\torch\_dynamo\external_utils.py", line 17, in inner
    return fn(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\torch\utils\checkpoint.py", line 451, in checkpoint
    return CheckpointFunction.apply(function, preserve, *args)
  File "C:\Train\kohya\venv\lib\site-packages\torch\autograd\function.py", line 539, in apply
    return super().apply(*args, **kwargs)  # type: ignore[misc]
  File "C:\Train\kohya\venv\lib\site-packages\torch\utils\checkpoint.py", line 230, in forward
    outputs = run_function(*args)
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 380, in forward
    hidden_states, attn_weights = self.self_attn(
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 269, in forward
    query_states = self.q_proj(hidden_states) * self.scale
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
    return self._call_impl(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
    return forward_call(*args, **kwargs)
  File "C:\Train\kohya\venv\lib\site-packages\lycoris\modules\dylora.py", line 148, in forward
    return self.bypass_forward(x, self.multiplier)
  File "C:\Train\kohya\venv\lib\site-packages\lycoris\modules\dylora.py", line 141, in bypass_forward
    return self.org_forward(x) + self.bypass_forward_diff(x, scale, rank)
  File "C:\Train\kohya\venv\lib\site-packages\lycoris\modules\dylora.py", line 138, in bypass_forward_diff
    return self.op(self.op(x, down, **self.kw_dict), up)
RuntimeError: mat1 and mat2 shapes cannot be multiplied (462x768 and 576x64)
steps:   0%|                                                                                 | 0/10000 [00:00<?, ?it/s]
Traceback (most recent call last):
  File "C:\Python310\lib\runpy.py", line 196, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "C:\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "C:\Train\kohya\venv\Scripts\accelerate.EXE\__main__.py", line 7, in <module>
  File "C:\Train\kohya\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 47, in main
    args.func(args)
  File "C:\Train\kohya\venv\lib\site-packages\accelerate\commands\launch.py", line 1017, in launch_command
    simple_launcher(args)
  File "C:\Train\kohya\venv\lib\site-packages\accelerate\commands\launch.py", line 637, in simple_launcher
    raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)
subprocess.CalledProcessError: Command '['C:\\Train\\kohya\\venv\\Scripts\\python.exe', 'C:/Train/kohya/sd-scripts/sdxl_train_network.py', '--config_file', 'C:\\Train\\train model/config_lora-20241002-132305.toml']' returned non-zero exit status 1.
TeKett commented 3 weeks ago

Would love to find a fix for this, since it is still not working

kohya-ss commented 2 weeks ago

Unfortunately, I don't know the cause of the LyCORIS error. How about using the dev branch of sd-scripts?