Comments (19)
After making the file edit noted in #37 to delete "dtype=weight_dtype", restarting server, and unchecking don't cache latents, unchecking train text encoder, and switching mixed precision to fp16, and setting generate preview to a really high number, set it to save checkpoint at the same number as my training steps, it's finally training! First time I've been able to Dreambooth train locally on my 3060 12GB.
Will take about a half hour to train 2000 steps.
from sd_dreambooth_extension.
I want to report that I just completed my first successful training on 3060 12GB... commit c1702f1. So it can be done!
Could you be so kind as to document your settings here:
I'd like to create a central place for folks to discuss tuning and setup, and I think your success story might be a good starting point. :D
from sd_dreambooth_extension.
Uncheck train text encoder if you haven't tried that.
from sd_dreambooth_extension.
I'd also suggest unchecking "train text encoder". It uses a big chunk of VRAM. You can also set "save checkpoint every" and "save image every" to 0 to ensure that doesn't try to use any VRAM.
from sd_dreambooth_extension.
@d8ahazard @rabidcopy Doesn't even manage to get to the Out of Memory part if I uncheck the train text encoder option. Instead throws out:
Traceback (most recent call last):
File "C:\StableDif\stable-diffusion-webui\modules\ui.py", line 185, in f
res = list(func(*args, **kwargs))
File "C:\StableDif\stable-diffusion-webui\webui.py", line 54, in f
res = func(*args, **kwargs)
File "C:\StableDif\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\dreambooth.py", line 265, in start_training
trained_steps = main(config)
File "C:\StableDif\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 769, in main
encoder_hidden_states = text_encoder(batch["input_ids"])[0]
File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs)
File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 722, in forward
return self.text_model(
File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs)
File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 643, in forward
encoder_outputs = self.encoder(
File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs)
File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 574, in forward
layer_outputs = encoder_layer(
File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs)
File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 317, in forward
hidden_states, attn_weights = self.self_attn(
File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs)
File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 257, in forward
attn_output = torch.bmm(attn_probs, value_states)
RuntimeError: expected scalar type Half but found Float
from sd_dreambooth_extension.
same card, same problem
from sd_dreambooth_extension.
same problem with 080ti 11GB tried everything, for that matter cpu doesnt work either.
from sd_dreambooth_extension.
@d8ahazard @rabidcopy Doesn't even manage to get to the Out of Memory part if I uncheck the train text encoder option. Instead throws out: Traceback (most recent call last): File "C:\StableDif\stable-diffusion-webui\modules\ui.py", line 185, in f res = list(func(*args, **kwargs)) File "C:\StableDif\stable-diffusion-webui\webui.py", line 54, in f res = func(*args, **kwargs) File "C:\StableDif\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\dreambooth.py", line 265, in start_training trained_steps = main(config) File "C:\StableDif\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 769, in main encoder_hidden_states = text_encoder(batch["input_ids"])[0] File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 722, in forward return self.text_model( File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 643, in forward encoder_outputs = self.encoder( File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 574, in forward layer_outputs = encoder_layer( File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 317, in forward hidden_states, attn_weights = self.self_attn( File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1130, in _call_impl return forward_call(*input, **kwargs) File "C:\StableDif\stable-diffusion-webui\venv\lib\site-packages\transformers\models\clip\modeling_clip.py", line 257, in forward attn_output = torch.bmm(attn_probs, value_states) RuntimeError: expected scalar type Half but found Float
See here #37 for a temp fix.
from sd_dreambooth_extension.
same problem, when uncheck the train text encoder option, nothing changed still same
from sd_dreambooth_extension.
I havnt use it yet, but with this GUI https://github.com/smy20011/dreambooth-gui it works well for 3060, even with text encoding ON.
from sd_dreambooth_extension.
I get this error under RTX 3060 12 GB, when after saved ckpt file:
Exception saving preview: tensors used as indices must be long, byte or bool tensors
Pipeline cleared...
Allocated: 3.7GB
Reserved: 4.5GB
Traceback (most recent call last):
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\modules\ui.py", line 185, in f
res = list(func(*args, **kwargs))
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\webui.py", line 54, in f
res = func(*args, **kwargs)
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\dreambooth.py", line 265, in start_training
trained_steps = main(config)
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 791, in main
optimizer.step()
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\accelerate\optimizer.py", line 134, in step
self.scaler.step(self.optimizer, closure)
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\torch\cuda\amp\grad_scaler.py", line 334, in step
self.unscale_(optimizer)
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\torch\cuda\amp\grad_scaler.py", line 279, in unscale_
optimizer_state["found_inf_per_device"] = self.unscale_grads(optimizer, inv_scale, found_inf, False)
Generate a preview image every N steps to 0 no helped. :(
@d8ahazard Didn't this latest patch break something?
from sd_dreambooth_extension.
I have a RTX3060 12GB, and I'm getting the same OOM and errors...
from sd_dreambooth_extension.
Unfortunately I got a different error at the end of training, after reaching the final training step, about not being able to parse config.json, and unable to connect to huggingface.co... anyone know what that might be about?
from sd_dreambooth_extension.
I also got an error when generating the image:
Exception saving preview: tensors used as indices must be long, byte or bool tensors
Pipeline cleared...
Allocated: 3.7GB
Reserved: 4.5GB
Error completing request
Arguments: ('myprompt', 'H:\Stable-Diffusion-Automatic\Dreambooth\destfront', 'H:\Stable-Diffusion-Automatic\stable-diffusion-webui\models\dreambooth\myprompt\classifiers', 'myprompt', '', '', '', 1.0, 7.5, 40.0, 0, 512, False, True, 1, 1, 12, 1500, 1, True, 5e-06, False, 'constant', 0, True, 0.9, 0.999, 0.01, 1e-08, 1, 100, 500, 'fp16', False, "[{'instance_prompt': 'myprompt', 'class_prompt': '', 'instance_data_dir': 'H:\\Stable-Diffusion-Automatic\\Dreambooth\\destfront', 'class_data_dir': 'H:\\Stable-Diffusion-Automatic\\stable-diffusion-webui\\models\\dreambooth\\myprompt\\classifiers'}]", False, True, True) {}
Traceback (most recent call last):
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\modules\ui.py", line 185, in f
res = list(func(*args, **kwargs))
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\webui.py", line 54, in f
res = func(*args, **kwargs)
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\dreambooth.py", line 265, in start_training
trained_steps = main(config)
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 791, in main
save_dir = args.output_dir
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\accelerate\optimizer.py", line 134, in step
self.scaler.step(self.optimizer, closure)
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\torch\cuda\amp\grad_scaler.py", line 334, in step
self.unscale_(optimizer)
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\torch\cuda\amp\grad_scaler.py", line 279, in unscale_
optimizer_state["found_inf_per_device"] = self.unscale_grads(optimizer, inv_scale, found_inf, False)
File "H:\Stable-Diffusion-Automatic\stable-diffusion-webui\venv\lib\site-packages\torch\cuda\amp\grad_scaler.py", line 207, in unscale_grads
raise ValueError("Attempting to unscale FP16 gradients.")
ValueError: Attempting to unscale FP16 gradients.
from sd_dreambooth_extension.
Unfortunately I got a different error at the end of training, after reaching the final training step, about not being able to parse config.json, and unable to connect to huggingface.co... anyone know what that might be about?
I got the same. Training starts successfully after the tweaks but if it pauses or stops for anything (including genrating sample images) it crashes:
OSError: We couldn't connect to 'https://huggingface.co' to load this model, couldn't find it in the cached files and it looks like E:\stable-diffusion-webui\models\dreambooth\Stolas\working is not the path to a directory containing a config.json file.
Checkout your internet connection or see how to run the library in offline mode at 'https://huggingface.co/docs/transformers/installation#offline-mode'.
from sd_dreambooth_extension.
After making the file edit noted in #37 to delete "dtype=weight_dtype", restarting server, and unchecking don't cache latents, unchecking train text encoder, and switching mixed precision to fp16, and setting generate preview to a really high number, set it to save checkpoint at the same number as my training steps, it's finally training! First time I've been able to Dreambooth train locally on my 3060 12GB.
Will take about a half hour to train 2000 steps.
+check 8bit adam
from sd_dreambooth_extension.
8bit adam is checked, issue persists
from sd_dreambooth_extension.
According to this page AUTOMATIC1111/stable-diffusion-webui#4436 there is a way to unload the VAE and save 2+ Gb, but I did not manage to find the setting.
from sd_dreambooth_extension.
I want to report that I just completed my first successful training on 3060 12GB... commit c1702f1. So it can be done!
from sd_dreambooth_extension.
Related Issues (20)
- Lora appears to be created during training but once complete it doesn't produce expected results[Bug]: HOT 13
- [Bug]: Can't create model using trained & generated model using dreambooth. HOT 3
- [Bug]: Exception training model: 'Cannot copy out of meta tensor; no data!'. HOT 2
- [Bug]: HOT 1
- [Bug]: The deprecation tuple ('LoRAAttnProcessor2_0', '0.26.0', 'Make sure use AttnProcessor2_0 instead by settingLoRA layers to `self.{to_q,to_k,to_v,to_out[0]}.lora_layer` respectively. This will be done automatically when using `LoraLoaderMixin.load_lora_weights`') should be removed since diffusers' version 0.26.1 is >= 0.26.0 HOT 4
- [Bug]: Completely unable to train any LORA with CUDA out of memory error HOT 2
- RuntimeError: Expected query, key, and value to have the same dtype, but got query.dtype: c10::Half key.dtype: float and value.dtype: float instead. HOT 9
- [Bug]: HOT 1
- [Bug]: OSError: Can't load tokenizer for 'laion/CLIP-ViT-bigG-14-laion2B-39B-b160k'. HOT 2
- [Bug]: TypeError: intercept_args() got an unexpected keyword argument 'multiprocessing_context' HOT 1
- Error al cargar sd_dreambooth_extension en Windows 10: 'LoRAAttnProcessor2_0' no definido HOT 1
- [Bug]: Dreambooth (input tab) not showing correctly HOT 10
- [Bug]: Exception training model: 'type object 'LoraLoaderMixin' has no attribute '_modify_text_encoder''. HOT 4
- [Bug]: AttributeError: 'NoneType' object has no attribute 'unscale_grads' HOT 1
- [Bug]: Unable to further train using previously trained ckpt in dreambooth. HOT 1
- [Bug]: Dreambooth can not start training HOT 3
- AttributeError: module 'jax.random' has no attribute 'KeyArray'[Bug]: HOT 1
- [Bug]: Fast api of concepts don't work HOT 2
- [Bug]: AttributeError: 'NoneType' object has no attribute 'keys' HOT 1
- [Bug]: Unable to do training on sdxl model HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sd_dreambooth_extension.