d8ahazard / sd_dreambooth_extension

Other
1.85k stars 283 forks source link

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0 #1435

Closed itasky closed 5 months ago

itasky commented 6 months ago

after starting the training i get this error and no model will be created. the training starts, saves 2 samples images but when it should save the 3th i get this error for the next whole process

i am using Automatic1111 1.7 python: 3.10.6 torch: 2.1.2+cu121  

with AMD Ryzen9 5950x RTX 4090

this is my webui-user.bat @echo off set PYTHON= set GIT= set VENV_DIR= set COMMANDLINE_ARGS= --xformers --opt-sdp-no-mem-attention --theme=dark --no-half-vae --opt-channelslast set CUDA_VISIBLE_DEVICES=0 git pull call webui.bat

more info:

Collecting environment information... PyTorch version: 2.1.2+cu121 Is debug build: False CUDA used to build PyTorch: 12.1 ROCM used to build PyTorch: N/A

OS: Microsoft Windows 11 Pro GCC version: Could not collect Clang version: Could not collect CMake version: Could not collect Libc version: N/A

Python version: 3.10.6 (tags/v3.10.6:9c7b4bd, Aug 1 2022, 21:53:49) [MSC v.1932 64 bit (AMD64)] (64-bit runtime) Python platform: Windows-10-10.0.22621-SP0 Is CUDA available: True CUDA runtime version: Could not collect CUDA_MODULE_LOADING set to: LAZY GPU models and configuration: GPU 0: NVIDIA GeForce RTX 4090 Nvidia driver version: 546.33 cuDNN version: Could not collect HIP runtime version: N/A MIOpen runtime version: N/A Is XNNPACK available: True

CPU: Architecture=9 CurrentClockSpeed=4200 DeviceID=CPU0 Family=107 L2CacheSize=8192 L2CacheSpeed= Manufacturer=AuthenticAMD MaxClockSpeed=4200 Name=AMD Ryzen 9 5950X 16-Core Processor ProcessorType=3 Revision=8448

Versions of relevant libraries: [pip3] mypy-extensions==1.0.0 [pip3] numpy==1.23.5 [pip3] open-clip-torch==2.20.0 [pip3] pytorch-lightning==1.9.4 [pip3] pytorch_optimizer==2.12.0 [pip3] torch==2.1.2+cu121 [pip3] torchaudio==2.1.2+cu121 [pip3] torchdiffeq==0.2.3 [pip3] torchmetrics==1.2.1 [pip3] torchsde==0.2.6 [pip3] torchvision==0.16.2+cu121 [conda] Could not collect

itasky commented 6 months ago

Initializing dreambooth training... Init dataset!set: 0%| | 0/5 [00:00<?, ?it/s] Preparing Dataset (Without Caching) Bucket 0 (512, 512, 0) - Instance Images: 10 | Class Images: 50 | Max Examples/batch: 20 Saving cache!mages...: 100%|██████████████████████████████████████████████████████████| 60/60 [00:00<00:00, 4789.57it/s] Total Buckets 1 - Instance Images: 10 | Class Images: 50 | Max Examples/batch: 20

Total images / batch: 20, total examples: 20█████████████████████████████████████████| 60/60 [00:00<00:00, 3520.43it/s] Initializing bucket counter! wandb: Tracking run with wandb version 0.16.1 wandb: W&B syncing is set to offline in this directory. wandb: Run wandb online or set WANDB_MODE=online to enable cloud syncing. Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:01<00:00, 6.01it/s] Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:01<00:00, 3.82it/s] Saving diffusion model: 100%|████████████████████████████████████████████████████████████| 1/1 [00:02<00:00, 2.87s/it]Model name: immobile6 50%|████████████████████████████████ | 2/4 [00:30<00:31, 15.93s/it] Saving G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\loss_plot_100.png Saving G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\ram_plot_100.png Cleanup log parse. Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:01<00:00, 6.13it/s] Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:01<00:00, 3.74it/s] Saving diffusion model: 100%|████████████████████████████████████████████████████████████| 1/1 [00:02<00:00, 2.68s/it]WARNING:dreambooth.train_dreambooth:Exception saving sample. | 0/4 [00:00<?, ?it/s] Traceback (most recent call last): File "G:\Automatic1111\sd.webui\webui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 1335, in save_weights s_image = s_pipeline( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(*args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion.py", line 933, in call prompt_embeds, negative_prompt_embeds = self.encode_prompt( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion.py", line 403, in encode_prompt prompt_embeds = self.text_encoder(text_input_ids.to(device), attention_mask=attention_mask) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 822, in forward return self.text_model( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 730, in forward hidden_states = self.embeddings(input_ids=input_ids, position_ids=position_ids) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 227, in forward inputs_embeds = self.token_embedding(input_ids) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\sparse.py", line 162, in forward return F.embedding( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\functional.py", line 2233, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_CUDAindex_select) Model name: immobile6 Log file updated, re-parsing: G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\dreambooth\events.out.tfevents.1704660012.DESKTOP-OR3CMG1.27892.2 Saving G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\loss_plot_200.png Saving G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\ram_plot_200.png Cleanup log parse. Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:01<00:00, 6.08it/s] Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:01<00:00, 3.89it/s] Saving diffusion model: 100%|████████████████████████████████████████████████████████████| 1/1 [00:02<00:00, 2.57s/it]WARNING:dreambooth.train_dreambooth:Exception saving sample. | 0/4 [00:00<?, ?it/s] Traceback (most recent call last): File "G:\Automatic1111\sd.webui\webui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 1335, in save_weights s_image = s_pipeline( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(*args, **kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion.py", line 933, in call prompt_embeds, negative_prompt_embeds = self.encode_prompt( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion.py", line 403, in encode_prompt prompt_embeds = self.text_encoder(text_input_ids.to(device), attention_mask=attention_mask) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 822, in forward return self.text_model( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 730, in forward hidden_states = self.embeddings(input_ids=input_ids, position_ids=position_ids) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 227, in forward inputs_embeds = self.token_embedding(input_ids) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\sparse.py", line 162, in forward return F.embedding( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\functional.py", line 2233, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select) Model name: immobile6 Log file updated, re-parsing: G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\dreambooth\events.out.tfevents.1704660012.DESKTOP-OR3CMG1.27892.2 Saving G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\loss_plot_300.png Saving G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\ram_plot_300.png Cleanup log parse. Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:01<00:00, 5.92it/s] Loading pipeline components...: 100%|████████████████████████████████████████████████████| 7/7 [00:02<00:00, 3.40it/s] Saving diffusion model: 100%|████████████████████████████████████████████████████████████| 1/1 [00:02<00:00, 2.93s/it]WARNING:dreambooth.train_dreambooth:Exception saving sample. | 0/4 [00:00<?, ?it/s] Traceback (most recent call last): File "G:\Automatic1111\sd.webui\webui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 1335, in save_weights s_image = s_pipeline( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\utils_contextlib.py", line 115, in decorate_context return func(args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion.py", line 933, in call__ prompt_embeds, negative_prompt_embeds = self.encode_prompt( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\diffusers\pipelines\stable_diffusion\pipeline_stable_diffusion.py", line 403, in encode_prompt prompt_embeds = self.text_encoder(text_input_ids.to(device), attention_mask=attention_mask) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, *kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 822, in forward return self.text_model( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(*args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 730, in forward hidden_states = self.embeddings(input_ids=input_ids, position_ids=position_ids) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\transformers\models\clip\modeling_clip.py", line 227, in forward inputs_embeds = self.token_embedding(input_ids) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl return self._call_impl(*args, *kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl return forward_call(args, **kwargs) File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\modules\sparse.py", line 162, in forward return F.embedding( File "C:\Users\manue\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\nn\functional.py", line 2233, in embedding return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select) Model name: immobile6 Log file updated, re-parsing: G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\dreambooth\events.out.tfevents.1704660012.DESKTOP-OR3CMG1.27892.2 Saving G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\loss_plot_336.png Saving G:\Automatic1111\sd.webui\webui\models\dreambooth\immobile6\logging\ram_plot_336.png Cleanup log parse. Cleanup completed. | 0/4 [00:00<?, ?it/s] wandb: wandb: wandb: Run history: wandb: epoch_loss ▁▂▅▂▆▁▄█▄▅▂▄▂▄█▂▇▂▅▁▆█▃▆▂▄▁▅▇▂▆▁▄▁▂▆▂▅▂▆ wandb: inst_loss ▁▃▁▁▆▃▁▂▁▁▃▂▂▁▄▆▄▅▁▄▂▄▄▄▁▁▂▃▁▄▁▂▄▁▁▆▂▃█▁ wandb: loss ▁▃▁▁▆▃▁▂▁▁▃▂▂▁▄▆▄▅▁▄▂▄▄▄▁▁▂▃▁▄▁▂▄▁▁▆▂▃█▁ wandb: lr ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁ wandb: vram ▁▁▁▁▁▁▁▁▁▁▁▁████████████████████████████ wandb: wandb: Run summary: wandb: epoch_loss 0.92403 wandb: inst_loss 0.03606 wandb: loss 0.03606 wandb: lr 0.0 wandb: vram 18.1 wandb: wandb: You can sync this run to the cloud by running: wandb: wandb sync G:\Automatic1111\sd.webui\webui\wandb\offline-run-20240107_214012-i7l96qm3 wandb: Find logs at: .\wandb\offline-run-20240107_214012-i7l96qm3\logs Steps: 13%|▌ | 336/2600 [02:42<18:16, 2.06it/s, inst_loss=0.0361, loss=0.0361, lr=1e-6, prior_loss=None, vram=18.1] Duration: 00:02:56 Duration: 00:02:57

github-actions[bot] commented 5 months ago

This issue is stale because it has been open 5 days with no activity. Remove stale label or comment or this will be closed in 5 days