kohya-ss / sd-scripts

Apache License 2.0
5.08k stars 849 forks source link

Python 3.11 #887

Open radry opened 11 months ago

radry commented 11 months ago

Please make it compatible with Python 3.11

13:56:35-478694 INFO     Configuring accelerate...
Traceback (most recent call last):
  File "<frozen runpy>", line 198, in _run_module_as_main
  File "<frozen runpy>", line 88, in _run_code
  File "G:\_AI\Stable Diffusion\_Training\kohya_ss\venv\Scripts\accelerate.exe\__main__.py", line 4, in <module>
  File "G:\_AI\Stable Diffusion\_Training\kohya_ss\venv\Lib\site-packages\accelerate\commands\accelerate_cli.py", line 21, in <module>
    from accelerate.commands.estimate import estimate_command_parser
  File "G:\_AI\Stable Diffusion\_Training\kohya_ss\venv\Lib\site-packages\accelerate\commands\estimate.py", line 35, in <module>
    import timm
  File "G:\_AI\Stable Diffusion\_Training\kohya_ss\venv\Lib\site-packages\timm\__init__.py", line 2, in <module>
    from .models import create_model, list_models, is_model, list_modules, model_entrypoint, \
  File "G:\_AI\Stable Diffusion\_Training\kohya_ss\venv\Lib\site-packages\timm\models\__init__.py", line 28, in <module>
    from .maxxvit import *
  File "G:\_AI\Stable Diffusion\_Training\kohya_ss\venv\Lib\site-packages\timm\models\maxxvit.py", line 225, in <module>
    @dataclass
     ^^^^^^^^^
  File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 1230, in dataclass
    return wrap(cls)
           ^^^^^^^^^
  File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 1220, in wrap
    return _process_class(cls, init, repr, eq, order, unsafe_hash,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 958, in _process_class
    cls_fields.append(_get_field(cls, name, type, kw_only))
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\xyz\AppData\Local\Programs\Python\Python311\Lib\dataclasses.py", line 815, in _get_field
    raise ValueError(f'mutable default {type(f.default)} for field '
ValueError: mutable default <class 'timm.models.maxxvit.MaxxVitConvCfg'> for field conv_cfg is not allowed: use default_factory
kohya-ss commented 11 months ago

It seems to be timm or accelerate issue. I think it will be better to ask in their repo.

If something wrong in the scripts on my repo, I will update to support Python 3.11.

radry commented 11 months ago

Ok. I did some research and I think Python 3.11 is still a problem because there is no xformers version that supports it.