TypeError: float() argument must be a string or a real number, not 'NoneType'
tkittich opened this issue · 7 comments
Hello,
I got the following error during training
`
╭────────────────────────── Traceback (most recent call last) ───────────────────────────╮
│ D:\theera\aiart\kohya_ss\train_network.py:864 in │
│ │
│ 861 │ args = parser.parse_args() │
│ 862 │ args = train_util.read_config_from_file(args, parser) │
│ 863 │ │
│ ❱ 864 │ train(args) │
│ 865 │
│ │
│ D:\theera\aiart\kohya_ss\train_network.py:214 in train │
│ │
│ 211 │ │ network, _ = network_module.create_network_from_weights(1, args.network_ │
│ 212 │ else: │
│ 213 │ │ # LyCORIS will work with this... │
│ ❱ 214 │ │ network = network_module.create_network( │
│ 215 │ │ │ 1.0, args.network_dim, args.network_alpha, vae, text_encoder, unet, │
│ 216 │ │ ) │
│ 217 │ if network is None: │
│ │
│ D:\theera\aiart\kohya_ss\venv\lib\site-packages\lycoris\kohya.py:23 in create_network │
│ │
│ 20 │ │ network_dim = 4 # default │
│ 21 │ conv_dim = int(kwargs.get('conv_dim', network_dim)) │
│ 22 │ conv_alpha = float(kwargs.get('conv_alpha', network_alpha)) │
│ ❱ 23 │ dropout = float(kwargs.get('dropout', 0.)) │
│ 24 │ algo = kwargs.get('algo', 'lora') │
│ 25 │ use_cp = (not kwargs.get('disable_conv_cp', True) │
│ 26 │ │ │ or kwargs.get('use_conv_cp', False)) │
╰────────────────────────────────────────────────────────────────────────────────────────╯
TypeError: float() argument must be a string or a real number, not 'NoneType'
╭────────────────────────── Traceback (most recent call last) ───────────────────────────╮
│ C:\Program Files\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:\Program Files\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 │
│ │
│ D:\theera\aiart\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": │
│ │
│ D:\theera\aiart\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py:1104 in │
│ launch_command │
│ │
│ 1101 │ elif defaults is not None and defaults.compute_environment == ComputeEnviro │
│ 1102 │ │ sagemaker_launcher(defaults, args) │
│ 1103 │ else: │
│ ❱ 1104 │ │ simple_launcher(args) │
│ 1105 │
│ 1106 │
│ 1107 def main(): │
│ │
│ D:\theera\aiart\kohya_ss\venv\lib\site-packages\accelerate\commands\launch.py:567 in │
│ simple_launcher │
│ │
│ 564 │ process = subprocess.Popen(cmd, env=current_env) │
│ 565 │ process.wait() │
│ 566 │ if process.returncode != 0: │
│ ❱ 567 │ │ raise subprocess.CalledProcessError(returncode=process.returncode, cmd= │
│ 568 │
│ 569 │
│ 570 def multi_gpu_launcher(args): │
╰────────────────────────────────────────────────────────────────────────────────────────╯
CalledProcessError: Command '['D:\theera\aiart\kohya_ss\venv\Scripts\python.exe',
'train_network.py', '--enable_bucket',
'--pretrained_model_name_or_path=D:/theera/aiart/stable-diffusion-webui/models/Stable-diff
usion/v1-5-pruned-emaonly.safetensors',
'--train_data_dir=D:/theera/aiart/aiart/lpa15/img', '--resolution=1024,1024',
'--output_dir=D:/theera/aiart/aiart/lpa15/model',
'--logging_dir=D:/theera/aiart/aiart/lpa15/log', '--network_alpha=30',
'--save_model_as=safetensors', '--network_module=lycoris.kohya', '--network_args',
'conv_dim=16', 'conv_alpha=16', 'algo=loha', '--text_encoder_lr=2.5e-05',
'--unet_lr=5e-05', '--network_dim=30', '--output_name=lpa15haCc16s100n1v5-1024-30',
'--lr_scheduler_num_cycles=6', '--learning_rate=0.0001', '--lr_scheduler=cosine',
'--lr_warmup_steps=480', '--train_batch_size=3', '--max_train_steps=4800',
'--save_every_n_epochs=1', '--mixed_precision=bf16', '--save_precision=bf16',
'--seed=1234', '--caption_extension=.txt', '--cache_latents',
'--optimizer_type=AdamW8bit', '--max_data_loader_n_workers=0', '--max_token_length=225',
'--bucket_reso_steps=64', '--xformers', '--bucket_no_upscale', '--noise_offset=0.1']'
returned non-zero exit status 1.
`
+1
I just tried training a LoHA on my side with no issues... Can you try to pull the latest release, delete the venv folder and redo the setup.bat?
Hope this will fix the issue.
TypeError: float() argument must be a string or a real number, not 'NoneType'
Hello,
Still got the same error after deleting venv folder and redo setup.bat with the latest release commit aa9c94e .
Looks like this happens when network_dropout is set to 0. If it has a non-zero value (for example 0.01) then it works.
Maybe some issue with parsing the input value?
Looks like this happens when network_dropout is set to 0. If it has a non-zero value (for example 0.01) then it works. Maybe some issue with parsing the input value?
Oh... interesting... maybe I am still passing the value of 0 and kohya does not like it... let me check the code. Not sure what kohya expect... no value when dropout is 0... or pass it as 0...
OK, I found a work around for the kohya_ss train_network.py logic issue... He is forcing network_dropout on LoHA... but since you set it to 0 it is treated as "Null" as it is not initialised... So I will force the initialisation to 0.0 so it make train_network.py and LyCORIS happy.
Fixed in latest v21.7.5 release