LarryJane491 / Lora-Training-in-Comfy

This custom node lets you train LoRA directly in ComfyUI!
364 stars 50 forks source link

Any video tutorial on training? #15

Open jackylee1 opened 7 months ago

jackylee1 commented 7 months ago

Any video tutorial on training?thanjs

jackylee1 commented 7 months ago

[SDN-[37mINF[0m]: [37mraise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd)[0m [SDN-[37mINF[0m]: [37msubprocess.CalledProcessError: Command '['C:\Users\Administrator\AppData\Local\Programs\Python\Python310\python.exe', 'custom_nodes/Lora-Training-in-Comfy/sd-scripts/train_network.py', '--enable_bucket', '--pretrained_model_name_or_path=F:\Blender_ComfyUI\ComfyUI\models\checkpoints\AIGODLIKE鍗庝附_4000.ckpt', '--train_data_dir=F:/Blender_ComfyUI/ComfyUI/output/LoraTest', '--output_dir=models/loras', '--logging_dir=./logs', '--log_prefix=Desired', 'name', 'for', 'LoRA.', '--resolution=512,512', '--network_module=networks.lora', '--max_train_epochs=10', '--learning_rate=1e-4', '--unet_lr=1.e-4', '--text_encoder_lr=1.e-4', '--lr_scheduler=cosine_with_restarts', '--lr_warmup_steps=0', '--lr_scheduler_num_cycles=1', '--network_dim=32', '--network_alpha=32', '--output_name=Desired', 'name', 'for', 'LoRA.', '--train_batch_size=1', '--save_every_n_epochs=10', '--mixed_precision=fp16', '--save_precision=fp16', '--seed=6', '--cache_latents', '--prior_loss_weight=1', '--max_token_length=225', '--caption_extension=.txt', '--save_model_as=safetensors', '--min_bucket_reso=256', '--max_bucket_reso=1584', '--keep_tokens=0', '--xformers', '--shuffle_caption', '--clip_skip=1', '--optimizer_type=AdamW8bit', '--persistent_data_loader_workers', '--log_with=tensorboard', '--clip_skip=1', '--optimizer_type=AdamW8bit', '--persistent_data_loader_workers', '--log_with=tensorboard', '--clip_skip=1', '--optimizer_type=AdamW8bit', '--persistent_data_loader_workers', '--log_with=tensorboard', '--clip_skip=1', '--optimizer_type=AdamW8bit', '--persistent_data_loader_workers', '--log_with=tensorboard', '--clip_skip=1', '--optimizer_type=AdamW8bit', '--persistent_data_loader_workers', '--log_with=tensorboard', '--clip_skip=1', '--optimizer_type=AdamW8bit', '--persistent_data_loader_workers', '--log_with=tensorboard', '--clip_skip=2', '--optimizer_type=AdamW8bit', '--persistent_data_loader_workers', '--log_with=tensorboard']' returned non-zero exit status 1.[0m

[SDN-[37mINF[0m]: [37mTrain finished[0m

[SDN-[37mINF[0m]: [37mPrompt executed in 1.88 seconds[0m

jackylee1 commented 7 months ago

prepare optimizer, data loader etc. False The following directories listed in your path were found to be non-existent: {WindowsPath('D'), WindowsPath('/ComfyUI-aki/ComfyUI-aki-v1.2/.ext/lib')} D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\bitsandbytes\cuda_setup\main.py:167: UserWarning: D:\ComfyUI-aki\ComfyUI-aki-v1.2.ext did not contain ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] as expected! Searching further paths... warn(msg) The following directories listed in your path were found to be non-existent: {WindowsPath('//gitcode.net/overbill1683/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1'), WindowsPath('git+https')} The following directories listed in your path were found to be non-existent: {WindowsPath('https'), WindowsPath('//modelscope.cn/api/v1/studio/hanamizukiai/resolver/gradio/wheel/depth_anything-2024.1.22.0-py2.py3-none-any.whl')} The following directories listed in your path were found to be non-existent: {WindowsPath('//gitcode.net/overbill1683/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379'), WindowsPath('git+https')} The following directories listed in your path were found to be non-existent: {WindowsPath('https'), WindowsPath('//www.modelscope.cn/api/v1/studio/hanamizukiai/resolver/gradio/wheel/handrefinerportable-2024.1.18.0-py2.py3-none-any.whl')} The following directories listed in your path were found to be non-existent: {WindowsPath('git+https'), WindowsPath('//gitcode.net/overbill1683/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b')} The following directories listed in your path were found to be non-existent: {WindowsPath('https'), WindowsPath('//mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html https'), WindowsPath('//www.modelscope.cn/api/v1/studio/hanamizukiai/resolver/gradio/pypi-index/index.html'), WindowsPath('//mirrors.aliyun.com/pytorch-wheels/torch_stable.html https')} The following directories listed in your path were found to be non-existent: {WindowsPath('https'), WindowsPath('//mirrors.aliyun.com/pypi/simple')} The following directories listed in your path were found to be non-existent: {WindowsPath('https'), WindowsPath('//www.modelscope.cn/api/v1/studio/hanamizukiai/resolver/gradio/wheel/xformers-0.0.14.dev0+torch12-cp310-cp310-win_amd64.whl')} CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching in backup paths... The following directories listed in your path were found to be non-existent: {WindowsPath('/usr/local/cuda/lib64')} DEBUG: Possible options found for libcudart.so: set() CUDA SETUP: PyTorch settings found: CUDA_VERSION=118, Highest Compute Capability: 8.6. CUDA SETUP: To manually override the PyTorch CUDA version please see:https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md

jackylee1 commented 7 months ago

D:\ComfyUI-aki\ComfyUI-aki-v1.2.cache\pycache\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy/sd-scripts/train_network.py D:\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy/sd-scripts/train_network.py D:\ComfyUI-aki\ComfyUI-aki-v1.2\Lora-Training-in-Comfy-main/sd-scripts/train_network.py The following values were not passed to accelerate launch and had defaults used instead: --num_processes was set to a value of 1 --num_machines was set to a value of 1 --mixed_precision was set to a value of 'no' --dynamo_backend was set to a value of 'no' To avoid this warning pass in values for each of the problematic parameters or run accelerate config. D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\diffusers\utils\outputs.py:63: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead. torch.utils._pytree._register_pytree_node( D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\diffusers\utils\outputs.py:63: UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead. torch.utils._pytree._register_pytree_node( prepare tokenizer update token length: 225 Using DreamBooth method. prepare images. found directory F:\Blender_ComfyUI\ComfyUI\output\LoraTest\10_TTTEST contains 24 image files No caption file found for 1 images. Training will continue without captions for these images. If class token exists, it will be used. / 1枚の画像にキャプションファイルが見つかりませんでした。これらの画像についてはキャプションなしで学習を続行します。class tokenが存在する場合はそれを使います。 F:\Blender_ComfyUI\ComfyUI\output\LoraTest\10_TTTEST\T100001.png 240 train images with repeating. 0 reg images. no regularization images / 正則化画像が見つかりませんでした [Dataset 0] batch_size: 1 resolution: (512, 512) enable_bucket: True min_bucket_reso: 256 max_bucket_reso: 1584 bucket_reso_steps: 64 bucket_no_upscale: False

[Subset 0 of Dataset 0] image_dir: "F:\Blender_ComfyUI\ComfyUI\output\LoraTest\10_TTTEST" image_count: 24 num_repeats: 10 shuffle_caption: True keep_tokens: 0 caption_dropout_rate: 0.0 caption_dropout_every_n_epoches: 0 caption_tag_dropout_rate: 0.0 caption_prefix: None caption_suffix: None color_aug: False flip_aug: False face_crop_aug_range: None random_crop: False token_warmup_min: 1, token_warmup_step: 0, is_reg: False class_tokens: TTTEST caption_extension: .txt [Dataset 0] loading image sizes. make buckets number of images (including repeats) / 各bucketの画像枚数(繰り返し回数を含む) bucket 0: resolution (512, 512), count: 240 mean ar error (without repeats): 0.0 preparing accelerator loading model for process 0/1 load StableDiffusion checkpoint: D:\ComfyUI-aki\ComfyUI-aki-v1.2\models\checkpoints\revAnimated_v122.safetensors UNet2DConditionModel: 64, 8, 768, False, False loading u-net: loading vae: loading text encoder: Enable xformers for U-Net import network module: networks.lora [Dataset 0] caching latents. checking cache validity... caching latents... create LoRA network. base dim (rank): 32, alpha: 32.0 neuron dropout: p=None, rank dropout: p=None, module dropout: p=None create LoRA for Text Encoder: 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. False The following directories listed in your path were found to be non-existent: {WindowsPath('D'), WindowsPath('/ComfyUI-aki/ComfyUI-aki-v1.2/.ext/lib')} D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\bitsandbytes\cuda_setup\main.py:167: UserWarning: D:\ComfyUI-aki\ComfyUI-aki-v1.2.ext did not contain ['libcudart.so', 'libcudart.so.11.0', 'libcudart.so.12.0'] as expected! Searching further paths... warn(msg) The following directories listed in your path were found to be non-existent: {WindowsPath('//gitcode.net/overbill1683/CLIP.git@d50d76daa670286dd6cacf3bcd80b5e4823fc8e1'), WindowsPath('git+https')} The following directories listed in your path were found to be non-existent: {WindowsPath('https'), WindowsPath('//modelscope.cn/api/v1/studio/hanamizukiai/resolver/gradio/wheel/depth_anything-2024.1.22.0-py2.py3-none-any.whl')} The following directories listed in your path were found to be non-existent: {WindowsPath('//gitcode.net/overbill1683/GFPGAN.git@8d2447a2d918f8eba5a4a01463fd48e45126a379'), WindowsPath('git+https')} The following directories listed in your path were found to be non-existent: {WindowsPath('https'), WindowsPath('//www.modelscope.cn/api/v1/studio/hanamizukiai/resolver/gradio/wheel/handrefinerportable-2024.1.18.0-py2.py3-none-any.whl')} The following directories listed in your path were found to be non-existent: {WindowsPath('//gitcode.net/overbill1683/open_clip.git@bb6e834e9c70d9c27d0dc3ecedeebeaeb1ffad6b'), WindowsPath('git+https')} The following directories listed in your path were found to be non-existent: {WindowsPath('//www.modelscope.cn/api/v1/studio/hanamizukiai/resolver/gradio/pypi-index/index.html'), WindowsPath('//mirror.sjtu.edu.cn/pytorch-wheels/torch_stable.html https'), WindowsPath('https'), WindowsPath('//mirrors.aliyun.com/pytorch-wheels/torch_stable.html https')} The following directories listed in your path were found to be non-existent: {WindowsPath('//mirrors.aliyun.com/pypi/simple'), WindowsPath('https')} The following directories listed in your path were found to be non-existent: {WindowsPath('//www.modelscope.cn/api/v1/studio/hanamizukiai/resolver/gradio/wheel/xformers-0.0.14.dev0+torch12-cp310-cp310-win_amd64.whl'), WindowsPath('https')} CUDA_SETUP: WARNING! libcudart.so not found in any environmental path. Searching in backup paths... The following directories listed in your path were found to be non-existent: {WindowsPath('/usr/local/cuda/lib64')} DEBUG: Possible options found for libcudart.so: set() CUDA SETUP: PyTorch settings found: CUDA_VERSION=121, Highest Compute Capability: 8.6. CUDA SETUP: To manually override the PyTorch CUDA version please see:https://github.com/TimDettmers/bitsandbytes/blob/main/how_to_use_nonpytorch_cuda.md CUDA SETUP: Loading binary D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\bitsandbytes\libbitsandbytes_cuda121.so... argument of type 'WindowsPath' is not iterable CUDA SETUP: Problem: The main issue seems to be that the main CUDA runtime library was not detected. CUDA SETUP: Solution 1: To solve the issue the libcudart.so location needs to be added to the LD_LIBRARY_PATH variable CUDA SETUP: Solution 1a): Find the cuda runtime library via: find / -name libcudart.so 2>/dev/null CUDA SETUP: Solution 1b): Once the library is found add it to the LD_LIBRARY_PATH: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:FOUND_PATH_FROM_1a CUDA SETUP: Solution 1c): For a permanent solution add the export from 1b into your .bashrc file, located at ~/.bashrc CUDA SETUP: Solution 2: If no library was found in step 1a) you need to install CUDA. CUDA SETUP: Solution 2a): Download CUDA install script: wget https://raw.githubusercontent.com/TimDettmers/bitsandbytes/main/cuda_install.sh CUDA SETUP: Solution 2b): Install desired CUDA version to desired location. The syntax is bash cuda_install.sh CUDA_VERSION PATH_TO_INSTALL_INTO. CUDA SETUP: Solution 2b): For example, "bash cuda_install.sh 113 ~/local/" will download CUDA 11.3 and install into the folder ~/local Traceback (most recent call last): File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy\sd-scripts\train_network.py", line 1012, in trainer.train(args) File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy\sd-scripts\train_network.py", line 342, in train optimizer_name, optimizer_args, optimizer = train_util.get_optimizer(args, trainable_params) File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy\sd-scripts\library\train_util.py", line 3444, in get_optimizer import bitsandbytes as bnb File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\bitsandbytes__init__.py", line 6, in from . import cuda_setup, utils, research File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\bitsandbytes\research__init.py", line 1, in from . import nn File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\bitsandbytes\research\nn\init.py", line 1, in from .modules import LinearFP8Mixed, LinearFP8Global File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\bitsandbytes\research\nn\modules.py", line 8, in from bitsandbytes.optim import GlobalOptimManager File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\bitsandbytes\optim\init__.py", line 6, in from bitsandbytes.cextension import COMPILED_WITH_CUDA File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\bitsandbytes\cextension.py", line 20, in raise RuntimeError(''' RuntimeError: CUDA Setup failed despite GPU being available. Please run the following command to get more information: python -m bitsandbytes

    Inspect the output of the command and see if you can locate CUDA libraries. You might need to add them
    to your LD_LIBRARY_PATH. If you suspect a bug, please take the information from python -m bitsandbytes
    and open an issue at: https://github.com/TimDettmers/bitsandbytes/issues

Traceback (most recent call last): File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\accelerate\commands\launch.py", line 996, in main() File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\accelerate\commands\launch.py", line 992, in main launch_command(args) File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\accelerate\commands\launch.py", line 986, in launch_command simple_launcher(args) File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\accelerate\commands\launch.py", line 628, in simple_launcher raise subprocess.CalledProcessError(returncode=process.returncode, cmd=cmd) subprocess.CalledProcessError: Command '['D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\python.exe', 'custom_nodes/Lora-Training-in-Comfy/sd-scripts/train_network.py', '--enable_bucket', '--pretrained_model_name_or_path=D:\ComfyUI-aki\ComfyUI-aki-v1.2\models\checkpoints\revAnimated_v122.safetensors', '--train_data_dir=F:/Blender_ComfyUI/ComfyUI/output/LoraTest', '--output_dir=models/loras', '--logging_dir=./logs', '--log_prefix=susuefang', '--resolution=512,512', '--network_module=networks.lora', '--max_train_epochs=10', '--learning_rate=1e-4', '--unet_lr=1.e-4', '--text_encoder_lr=1.e-4', '--lr_scheduler=cosine_with_restarts', '--lr_warmup_steps=0', '--lr_scheduler_num_cycles=1', '--network_dim=32', '--network_alpha=32', '--output_name=susuefang', '--train_batch_size=1', '--save_every_n_epochs=10', '--mixed_precision=fp16', '--save_precision=fp16', '--seed=9', '--cache_latents', '--prior_loss_weight=1', '--max_token_length=225', '--caption_extension=.txt', '--save_model_as=safetensors', '--min_bucket_reso=256', '--max_bucket_reso=1584', '--keep_tokens=0', '--xformers', '--shuffle_caption', '--clip_skip=2', '--optimizer_type=AdamW8bit', '--persistent_data_loader_workers', '--log_with=tensorboard', '--clip_skip=2', '--optimizer_type=AdamW8bit', '--persistent_data_loader_workers', '--log_with=tensorboard']' returned non-zero exit status 1. Train finished Prompt executed in 28.09 seconds

LarryJane491 commented 7 months ago

Hey there. Video tutorial here: https://www.youtube.com/watch?v=mDMYbCz2t-c&t=106s&ab_channel=LarryJane

The errors your code is showing are new ones for me. But the core problem seems to be the same as the other open issues: it's a Python dependency problem. I can only suggest installing a virtual environment for your ComfyUI, and install everything there.

jackylee1 commented 7 months ago

loading u-net: loading vae: Traceback (most recent call last): File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy\sd-scripts\train_network.py", line 1012, in trainer.train(args) File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy\sd-scripts\train_network.py", line 228, in train model_version, text_encoder, vae, unet = self.load_target_model(args, weight_dtype, accelerator) File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy\sd-scripts\train_network.py", line 102, in load_target_model textencoder, vae, unet, = train_util.load_target_model(args, weight_dtype, accelerator) File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy\sd-scripts\library\train_util.py", line 3917, in load_target_model text_encoder, vae, unet, load_stable_diffusion_format = _load_target_model( File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy\sd-scripts\library\train_util.py", line 3860, in _load_target_model text_encoder, vae, unet = model_util.load_models_from_stable_diffusion_checkpoint( File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\custom_nodes\Lora-Training-in-Comfy\sd-scripts\library\model_util.py", line 1072, in load_models_from_stable_diffusion_checkpoint info = text_model.load_state_dict(converted_text_encoder_checkpoint) File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\torch\nn\modules\module.py", line 2153, in load_state_dict raise RuntimeError('Error(s) in loading state_dict for {}:\n\t{}'.format( RuntimeError: Error(s) in loading state_dict for CLIPTextModel: Unexpected key(s) in state_dict: "text_model.embeddings.position_ids". Traceback (most recent call last): File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\runpy.py", line 196, in _run_module_as_main return _run_code(code, main_globals, None, File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\runpy.py", line 86, in _run_code exec(code, run_globals) File "D:\ComfyUI-aki\ComfyUI-aki-v1.2\python\lib\site-packages\accelerate\commands\launch.py", line 996, in main()

new error

mrbeandev commented 4 months ago

so there are no fixed for these errors ? whats the use of even having this lib if now one can fix these !!

i amvery frustrated on this comifyui been on this for 1 week and tried all types of things nothing works fk !!!