kohya-ss / sd-scripts

Apache License 2.0
5.12k stars 852 forks source link

AttributeError: 'Namespace' object has no attribute 'noise_offset' #204

Open yvonnechen888 opened 1 year ago

yvonnechen888 commented 1 year ago

Hi All,

Any one knows how to fix this error? Or where can I skip this 'noise_offset' option?

running training / 学習開始 num train images * repeats / 学習画像の数×繰り返し回数: 1000 num reg images / 正則化画像の数: 0 num batches per epoch / 1epochのバッチ数: 1000 num epochs / epoch数: 1 batch size per device / バッチサイズ: 1 total train batch size (with parallel & distributed & accumulation) / 総バッチサイズ(並列学習、勾配合計含む): 1 gradient accumulation steps / 勾配を合計するステップ数 = 1 total optimization steps / 学習ステップ数: 1000 Traceback (most recent call last): File "C:\Users\Kohya\kohya_ss\train_network.py", line 573, in <module> train(args) File "C:\Users\Kohya\kohya_ss\train_network.py", line 356, in train "ss_noise_offset": args.noise_offset, AttributeError: 'Namespace' object has no attribute 'noise_offset' Traceback (most recent call last): File "C:\Users\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\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "C:\Users\Documents\Kohya\kohya_ss\venv\Scripts\accelerate.exe\__main__.py", line 7, in <module> File "C:\Users\Documents\Kohya\kohya_ss\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 45, in main args.func(args) File "C:\Users\Documents\Kohya\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py", line 1104, in launch_command simple_launcher(args) File "C:\Users\Documents\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\\Documents\\Kohya\\kohya_ss\\venv\\Scripts\\python.exe', 'train_network.py', '--enable_bucket', '--pretrained_model_name_or_path=E:/stable-diffusion-webui/models/Stable-diffusion/anything-v3-full.safetensors', '--train_data_dir=C:/Users/Documents/Kohya/Lora/Character/image', '--resolution=512,512', '--output_dir=C:/Users/Documents/Kohya/Lora/Character/model', '--logging_dir=C:/Users/Documents/Kohya/Lora/Character/log', '--network_alpha=1', '--save_model_as=safetensors', '--network_module=networks.lora', '--text_encoder_lr=5e-5', '--unet_lr=0.0001', '--network_dim=8', '--output_name=testman', '--lr_scheduler_num_cycles=1', '--learning_rate=0.0001', '--lr_scheduler=cosine', '--lr_warmup_steps=100', '--train_batch_size=1', '--max_train_steps=1000', '--save_every_n_epochs=1', '--mixed_precision=fp16', '--save_precision=fp16', '--seed=1234', '--cache_latents', '--bucket_reso_steps=64', '--xformers', '--use_8bit_adam', '--bucket_no_upscale']' returned non-zero exit status 1.

chrbratt commented 1 year ago

Same problem here. Latest update from repository. Any ide is welcome? :)


You have disabled the safety checker for <class 'diffusers.pipelines.stable_diffusion.pipeline_stable_diffusion.StableDiffusionPipeline'> by passing `safety_checker=None`. Ensure that you abide to the conditions of the Stable Diffusion license and do not expose unfiltered results in services or applications open to the public. Both the diffusers team and Hugging Face strongly recommend to keep the safety filter enabled in all public facing circumstances, disabling it only for use-cases that involve analyzing network behavior or auditing its results. For more information, please have a look at https://github.com/huggingface/diffusers/pull/254 .
Replace CrossAttention.forward to use xformers
caching latents.
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 48/48 [00:03<00:00, 14.02it/s]
import network module: networks.lora
create LoRA for Text Encoder: 72 modules.
create LoRA for U-Net: 192 modules.
enable LoRA for text encoder
enable LoRA for U-Net
prepare optimizer, data loader etc.

===================================BUG REPORT===================================
Welcome to bitsandbytes. For bug reports, please submit your error trace to: https://github.com/TimDettmers/bitsandbytes/issues
For effortless bug reporting copy-paste your error into this form: https://docs.google.com/forms/d/e/1FAIpQLScPB8emS3Thkp66nvqwmjTEgxp8Y9ufuWTzFyr9kJ5AoI47dQ/viewform?usp=sf_link
================================================================================
CUDA SETUP: Loading binary D:\kohya_ss\venv\lib\site-packages\bitsandbytes\libbitsandbytes_cuda116.dll...
use 8-bit Adam optimizer
running training / 学習開始
  num train images * repeats / 学習画像の数×繰り返し回数: 7200
  num reg images / 正則化画像の数: 0
  num batches per epoch / 1epochのバッチ数: 3600
  num epochs / epoch数: 1
  batch size per device / バッチサイズ: 2
  total train batch size (with parallel & distributed & accumulation) / 総バッチサイズ(並列学習、勾配合計含む): 2
  gradient accumulation steps / 勾配を合計するステップ数 = 1
  total optimization steps / 学習ステップ数: 3150
Traceback (most recent call last):
  File "D:\kohya_ss\train_network.py", line 573, in <module>
    train(args)
  File "D:\kohya_ss\train_network.py", line 356, in train
    "ss_noise_offset": args.noise_offset,
AttributeError: 'Namespace' object has no attribute 'noise_offset'
Traceback (most recent call last):
  File "C:\Users\bratt\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\bratt\AppData\Local\Programs\Python\Python310\lib\runpy.py", line 86, in _run_code
    exec(code, run_globals)
  File "D:\kohya_ss\venv\Scripts\accelerate.exe\__main__.py", line 7, in <module>
  File "D:\kohya_ss\venv\lib\site-packages\accelerate\commands\accelerate_cli.py", line 45, in main
    args.func(args)
  File "D:\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py", line 1104, in launch_command
    simple_launcher(args)
  File "D:\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 '['D:\\StableDiffusion\\kohya_ss\\venv\\Scripts\\python.exe', 'train_network.py', '--enable_bucket', '--pretrained_model_name_or_path=runwayml/stable-diffusion-v1-5', '--train_data_dir=D:\\StableDiffusion\\LoraTraining Data\\cbratt\\image', '--resolution=512,512', '--output_dir=D:\\StableDiffusion\\LoraTraining Data\\cbratt', '--logging_dir=D:\\StableDiffusion\\LoraTraining Data\\cbratt', '--network_alpha=1', '--save_model_as=safetensors', '--network_module=networks.lora', '--text_encoder_lr=5e-5', '--unet_lr=0.0001', '--network_dim=8', '--output_name=cbratt2', '--lr_scheduler_num_cycles=1', '--learning_rate=0.0001', '--lr_scheduler=cosine', '--lr_warmup_steps=315', '--train_batch_size=2', '--max_train_steps=3150', '--save_every_n_epochs=1', '--mixed_precision=fp16', '--save_precision=fp16', '--seed=1234', '--cache_latents', '--bucket_reso_steps=64', '--gradient_checkpointing', '--xformers', '--use_8bit_adam', '--bucket_no_upscale']' returned non-zero exit status 1.
chrbratt commented 1 year ago

This was the solution to my problem.

https://github.com/bmaltais/kohya_ss/issues/192#issuecomment-1435629534

Crimsonfart commented 1 year ago

This was the solution to my problem.

https://github.com/bmaltais/kohya_ss/issues/192#issuecomment-1435629534

Link is dead. Looks like someone is intentionally deleting all solutions on the topic. I my self also opened an "Issue" and everything was deleted.

kohya-ss commented 1 year ago

Hi, noise_offset is a newly added option, and train_util.py does not seem to be updated. Please upgrade the scripts according to Upgrade. https://github.com/kohya-ss/sd-scripts#upgrade

In addition, if you are using a wrapper script, please update the wrapper script or contact to the author of the script.

HWESTA00 commented 1 year ago

Hi, noise_offset is a newly added option, and train_util.py does not seem to be updated. Please upgrade the scripts according to Upgrade. https://github.com/kohya-ss/sd-scripts#upgrade

In addition, if you are using a wrapper script, please update the wrapper script or contact to the author of the script.

Still have problem It shows this SyntaxError: invalid character '·' (U+00B7)

yvonnechen888 commented 1 year ago

Thanks alot to @kohya-ss, issue fixed.

To anyone having the same issue: My train_util.py could not get upgrade, so I manually copied new code from code page: https://github.com/kohya-ss/sd-scripts/blob/main/library/train_util.py,

and replaced it with the train_util.py on my local computer. Then it works.

Swizzler121 commented 1 year ago

My train_util.py could not get upgrade, so I manually copied new code from code page, and replaced the train_util.py on my local computer.

I'm trying to replicate your fix and not having any luck, did you just pull the train_util.py from the master branch, or from the latest release?

Also, is there only one trainutil.py? I found one in the library folder, but there's so many train python scripts in this project I wouldn't be surprised if it's also elsewhere or in the venv or something.

EDIT: I was able to get it working by downloading the library/train_util.py from the master branch to the same directory on my install. I had to do a fresh reboot of my system to get it to work for some reason.

Trahloc commented 1 year ago

I opened kohya_ss\library\train_util.py in notepad++, then pasted the contents from the link @yvonnechen888 provided and was able to start training without even having to reload kohya-ss after it failed. I've never had much luck forcing git to overwrite a file it thought was up to date, manual copying and pasting works every time though.