kohya-ss / sd-scripts

Apache License 2.0
5.13k stars 855 forks source link

ModuleNotFoundError: No module named 'library.lpw_stable_diffusion' & raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd) subprocess.CalledProcessError #316

Closed AniMoster closed 11 months ago

AniMoster commented 1 year ago

I'm getting the following error even after replacing all 3 instances of train.util.py like mentioned Here

Can someone please help resolve this?

Traceback (most recent call last): File "C:\Users\name\Kohya\kohya_ss\train_network.py", line 16, in <module> import library.train_util as train_util File "C:\Users\name\Kohya\kohya_ss\library\train_util.py", line 59, in <module> from library.lpw_stable_diffusion import StableDiffusionLongPromptWeightingPipeline ModuleNotFoundError: No module named 'library.lpw_stable_diffusion' Traceback (most recent call last): File "C:\Users\name\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "C:\Users\name\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\name\Kohya\kohya_ss\venv\Scripts\accelerate.exe\__main__.py", line 7, in <module> File "C:\Users\name\Kohya\kohya_ss\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 45, in main args.func(args) File "C:\Users\name\Kohya\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py", line 1104, in launch_command simple_launcher(args) File "C:\Users\name\Kohya\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py", line 567, in simple_launcher raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd) subprocess.CalledProcessError: Command '['C:\\Users\\name\\Kohya\\kohya_ss\\venv\\Scripts\\python.exe', 'train_network.py', '--enable_bucket', '--pretrained_model_name_or_path=C:/Users/name/stable-diffusion-webui/models/Stable-diffusion/chilloutmix_NiPrunedFp32Fix.safetensors', '--train_data_dir=C:/Users/name/Kohya/LoRA/img', '--resolution=512,512', '--output_dir=C:/Users/name/Kohya/LoRA/model', '--logging_dir=C:/Users/name/Kohya/LoRA/log', '--network_alpha=128', '--save_model_as=safetensors', '--network_module=networks.lora', '--text_encoder_lr=5e-5', '--unet_lr=0.0001', '--network_dim=128', '--output_name=Ayane Sakura', '--lr_scheduler_num_cycles=1', '--learning_rate=0.0001', '--lr_scheduler=constant', '--train_batch_size=1', '--max_train_steps=4700', '--save_every_n_epochs=1', '--mixed_precision=fp16', '--save_precision=fp16', '--seed=1234', '--caption_extension=.txt', '--cache_latents', '--optimizer_type=AdamW', '--max_data_loader_n_workers=1', '--clip_skip=2', '--bucket_reso_steps=64', '--mem_eff_attn', '--gradient_checkpointing', '--xformers']' returned non-zero exit status 1.

kohya-ss commented 1 year ago

Please update the repo with pip install --use-pep517 --upgrade -r requirements.txt.

originpulses commented 1 year ago

I'm getting similar issue:

(venv) C:\Users\sabih\OneDrive\Desktop\Kohya\kohya_ss>gui.bat --listen 127.0.0.1 --server_port 7860 --inbrowser
Traceback (most recent call last):
  File "C:\Users\sabih\OneDrive\Desktop\Kohya\kohya_ss\tools\validate_requirements.py", line 6, in <module>
    from library.custom_logging import setup_logging
ModuleNotFoundError: No module named 'library.custom_logging'

Also I did this pip install --use-pep517 --upgrade -r requirements.txt

I am getting:

ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'
AsaTyr2018 commented 1 year ago

I got the latest release. but its not working. Tried the mentioned steps befor. (The whole Machine was freshly installed today)

got this error when i try caption:

20:51:54-853477 INFO accelerate launch "./finetune/tag_images_by_wd14_tagger.py" --batch_size=8 --general_threshold=0.35 --character_threshold=0.35 --caption_extension=".txt" --model="SmilingWolf/wd-v1-4-swinv2-tagger-v2" --max_data_loader_n_workers="2" --debug --remove_underscore --frequency_tags "C:\Lora-Trainer\StyleSet1\dataset" Traceback (most recent call last): File "C:\AI\trainer\kohya_ss\finetune\tag_images_by_wd14_tagger.py", line 14, in import library.train_util as train_util ModuleNotFoundError: No module named 'library' ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py:196 in │ │ _run_module_as_main │ │ │ │ 193 │ main_globals = sys.modules["main"].dict │ │ 194 │ if alter_argv: │ │ 195 │ │ sys.argv[0] = mod_spec.origin │ │ ❱ 196 │ return _run_code(code, main_globals, None, │ │ 197 │ │ │ │ │ "main", mod_spec) │ │ 198 │ │ 199 def run_module(mod_name, init_globals=None, │ │ │ │ C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py:86 in _run_code │ │ │ │ 83 │ │ │ │ │ loader = loader, │ │ 84 │ │ │ │ │ package = pkg_name, │ │ 85 │ │ │ │ │ spec = mod_spec) │ │ ❱ 86 │ exec(code, run_globals) │ │ 87 │ return run_globals │ │ 88 │ │ 89 def _run_module_code(code, init_globals=None, │ │ │ │ in :7 │ │ │ │ 4 from accelerate.commands.accelerate_cli import main │ │ 5 if name == 'main': │ │ 6 │ sys.argv[0] = re.sub(r'(-script.pyw|.exe)?$', '', sys.argv[0]) │ │ ❱ 7 │ sys.exit(main()) │ │ 8 │ │ │ │ C:\AI\trainer\kohya_ss\venv\lib\site-packages\accelerate\commands\accelerate_cli.py:45 in main │ │ │ │ 42 │ │ exit(1) │ │ 43 │ │ │ 44 │ # Run │ │ ❱ 45 │ args.func(args) │ │ 46 │ │ 47 │ │ 48 if name == "main": │ │ │ │ C:\AI\trainer\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py:918 in │ │ launch_command │ │ │ │ 915 │ elif defaults is not None and defaults.compute_environment == ComputeEnvironment.AMA │ │ 916 │ │ sagemaker_launcher(defaults, args) │ │ 917 │ else: │ │ ❱ 918 │ │ simple_launcher(args) │ │ 919 │ │ 920 │ │ 921 def main(): │ │ │ │ C:\AI\trainer\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py:580 in │ │ simple_launcher │ │ │ │ 577 │ process.wait() │ │ 578 │ if process.returncode != 0: │ │ 579 │ │ if not args.quiet: │ │ ❱ 580 │ │ │ raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd) │ │ 581 │ │ else: │ │ 582 │ │ │ sys.exit(1) │ │ 583 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ CalledProcessError: Command '['C:\AI\trainer\kohya_ss\venv\Scripts\python.exe', './finetune/tag_images_by_wd14_tagger.py', '--batch_size=8', '--general_threshold=0.35', '--character_threshold=0.35', '--caption_extension=.txt', '--model=SmilingWolf/wd-v1-4-swinv2-tagger-v2', '--max_data_loader_n_workers=2', '--debug', '--remove_underscore', '--frequency_tags', 'C:\Lora-Trainer\StyleSet1\dataset']' returned non-zero exit status 1. 20:52:03-693973 INFO ...captioning done

psklf commented 11 months ago

I got the latest release. but its not working. Tried the mentioned steps befor. (The whole Machine was freshly installed today)

got this error when i try caption:

20:51:54-853477 INFO accelerate launch "./finetune/tag_images_by_wd14_tagger.py" --batch_size=8 --general_threshold=0.35 --character_threshold=0.35 --caption_extension=".txt" --model="SmilingWolf/wd-v1-4-swinv2-tagger-v2" --max_data_loader_n_workers="2" --debug --remove_underscore --frequency_tags "C:\Lora-Trainer\StyleSet1\dataset" Traceback (most recent call last): File "C:\AI\trainer\kohya_ss\finetune\tag_images_by_wd14_tagger.py", line 14, in import library.train_util as train_util ModuleNotFoundError: No module named 'library' ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py:196 in │ │ _run_module_as_main │ │ │ │ 193 │ main_globals = sys.modules["main"].dict │ │ 194 │ if alter_argv: │ │ 195 │ │ sys.argv[0] = mod_spec.origin │ │ ❱ 196 │ return _run_code(code, main_globals, None, │ │ 197 │ │ │ │ │ "main", mod_spec) │ │ 198 │ │ 199 def run_module(mod_name, init_globals=None, │ │ │ │ C:\Users\Administrator\AppData\Local\Programs\Python\Python310\lib\runpy.py:86 in _run_code │ │ │ │ 83 │ │ │ │ │ loader = loader, │ │ 84 │ │ │ │ │ package = pkg_name, │ │ 85 │ │ │ │ │ spec = mod_spec) │ │ ❱ 86 │ exec(code, run_globals) │ │ 87 │ return run_globals │ │ 88 │ │ 89 def _run_module_code(code, init_globals=None, │ │ │ │ in :7 │ │ │ │ 4 from accelerate.commands.accelerate_cli import main │ │ 5 if name == 'main': │ │ 6 │ sys.argv[0] = re.sub(r'(-script.pyw|.exe)?$', '', sys.argv[0]) │ │ ❱ 7 │ sys.exit(main()) │ │ 8 │ │ │ │ C:\AI\trainer\kohya_ss\venv\lib\site-packages\accelerate\commands\accelerate_cli.py:45 in main │ │ │ │ 42 │ │ exit(1) │ │ 43 │ │ │ 44 │ # Run │ │ ❱ 45 │ args.func(args) │ │ 46 │ │ 47 │ │ 48 if name == "main": │ │ │ │ C:\AI\trainer\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py:918 in │ │ launch_command │ │ │ │ 915 │ elif defaults is not None and defaults.compute_environment == ComputeEnvironment.AMA │ │ 916 │ │ sagemaker_launcher(defaults, args) │ │ 917 │ else: │ │ ❱ 918 │ │ simple_launcher(args) │ │ 919 │ │ 920 │ │ 921 def main(): │ │ │ │ C:\AI\trainer\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py:580 in │ │ simple_launcher │ │ │ │ 577 │ process.wait() │ │ 578 │ if process.returncode != 0: │ │ 579 │ │ if not args.quiet: │ │ ❱ 580 │ │ │ raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd) │ │ 581 │ │ else: │ │ 582 │ │ │ sys.exit(1) │ │ 583 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ CalledProcessError: Command '['C:\AI\trainer\kohya_ss\venv\Scripts\python.exe', './finetune/tag_images_by_wd14_tagger.py', '--batch_size=8', '--general_threshold=0.35', '--character_threshold=0.35', '--caption_extension=.txt', '--model=SmilingWolf/wd-v1-4-swinv2-tagger-v2', '--max_data_loader_n_workers=2', '--debug', '--remove_underscore', '--frequency_tags', 'C:\Lora-Trainer\StyleSet1\dataset']' returned non-zero exit status 1. 20:52:03-693973 INFO ...captioning done

Try re-run pip install -r requirements.txt

kohya-ss commented 11 months ago

I think pip will solve the issue. Please re-open this if the issue remains.