stable-diffusion-webui icon indicating copy to clipboard operation
stable-diffusion-webui copied to clipboard

[Bug]: (MacOS) hypernetwork training - RuntimeError: Input type (MPSFloatType) and weight type (MPSHalfType) should be the same

Open humam-homo opened this issue 1 year ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues and checked the recent builds/commits

What happened?

i was using the hyper network and if i train it says "RuntimeError: Input type (MPSFloatType) and weight type (MPSHalfType) should be the same" could someone tell me the solution? 스크린샷 2023-01-29 오전 12 35 36

Steps to reproduce the problem

  1. i have mac
  2. went after prepossesing the images and creating the hypernetwork i went to train
  3. i typed in the dataset directory, changed the max steps to 2000 and rest to 200 and learning rate to 0.00005
  4. i clicked train and it said that

What should have happened?

It should've been trained

Commit where the problem happens

python: 3.10.6 • torch: 1.12.1+cpu • checkpoint: fbcf965a62

What platforms do you use to access the UI ?

MacOS

What browsers do you use to access the UI ?

Google Chrome

Command Line Arguments

no

List of extensions

no

Console logs

Checkpoint v1-5-pruned.ckpt [e1441589a6] not found; loading fallback anything-v4.5.ckpt [fbcf965a62]
Loading weights [fbcf965a62] from /Users/whtsz/stable-diffusion-webui/models/Stable-diffusion/anything-v4.5.ckpt
Applying cross attention optimization (InvokeAI).
Weights loaded in 55.0s (load weights from disk: 10.9s, apply weights to model: 12.7s, apply half(): 0.2s, move model to device: 31.0s).
Preprocessing [Image 23/24]: 100%|██████████████| 24/24 [00:09<00:00,  2.58it/s]
Calculating sha256 for /Users/whtsz/stable-diffusion-webui/models/hypernetworks/sample.pt: d6e3c2b9b76bd28f1ba47b848aef0020df98b04908331e76dfbf8c1d91815258
Checkpoint v1-5-pruned.ckpt [e1441589a6] not found; loading fallback anything-v4.5.ckpt [fbcf965a62]
Training at rate of 5e-05 until step 2000
Preparing dataset...
 29%|████████████▊                                | 2/7 [00:00<00:00, 31.92it/s]
Applying cross attention optimization (InvokeAI).
Error completing request
Arguments: ('task(x3kr8uu4q4uvcgv)', 'sample', '0.00005', 1, 1, '/Users/whtsz/Desktop/sample/sample b', 'textual_inversion', 512, 512, True, 2000, 'disabled', '0.1', False, 0, 'once', 100, 100, 'hypernetwork.txt', True, 'girl, black hair, sexy, cute, line', '', 20, 0, 5, -1.0, 512, 512) {}
Traceback (most recent call last):
  File "/Users/whtsz/stable-diffusion-webui/modules/call_queue.py", line 56, in f
    res = list(func(*args, **kwargs))
  File "/Users/whtsz/stable-diffusion-webui/modules/call_queue.py", line 37, in f
    res = func(*args, **kwargs)
  File "/Users/whtsz/stable-diffusion-webui/modules/hypernetworks/ui.py", line 27, in train_hypernetwork
    hypernetwork, filename = modules.hypernetworks.hypernetwork.train_hypernetwork(*args)
  File "/Users/whtsz/stable-diffusion-webui/modules/hypernetworks/hypernetwork.py", line 557, in train_hypernetwork
    ds = modules.textual_inversion.dataset.PersonalizedBase(data_root=data_root, width=training_width, height=training_height, repeats=shared.opts.training_image_repeats_per_epoch, placeholder_token=hypernetwork_name, model=shared.sd_model, cond_model=shared.sd_model.cond_stage_model, device=devices.device, template_file=template_file, include_cond=True, batch_size=batch_size, gradient_step=gradient_step, shuffle_tags=shuffle_tags, tag_drop_out=tag_drop_out, latent_sampling_method=latent_sampling_method, varsize=varsize)
  File "/Users/whtsz/stable-diffusion-webui/modules/textual_inversion/dataset.py", line 88, in __init__
    latent_dist = model.encode_first_stage(torchdata.unsqueeze(dim=0))
  File "/Users/whtsz/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/autograd/grad_mode.py", line 27, in decorate_context
    return func(*args, **kwargs)
  File "/Users/whtsz/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/diffusion/ddpm.py", line 830, in encode_first_stage
    return self.first_stage_model.encode(x)
  File "/Users/whtsz/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/models/autoencoder.py", line 83, in encode
    h = self.encoder(x)
  File "/Users/whtsz/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/Users/whtsz/stable-diffusion-webui/repositories/stable-diffusion-stability-ai/ldm/modules/diffusionmodules/model.py", line 523, in forward
    hs = [self.conv_in(x)]
  File "/Users/whtsz/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/module.py", line 1130, in _call_impl
    return forward_call(*input, **kwargs)
  File "/Users/whtsz/stable-diffusion-webui/extensions-builtin/Lora/lora.py", line 182, in lora_Conv2d_forward
    return lora_forward(self, input, torch.nn.Conv2d_forward_before_lora(self, input))
  File "/Users/whtsz/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 457, in forward
    return self._conv_forward(input, self.weight, self.bias)
  File "/Users/whtsz/stable-diffusion-webui/venv/lib/python3.10/site-packages/torch/nn/modules/conv.py", line 453, in _conv_forward
    return F.conv2d(input, weight, bias, self.stride,
RuntimeError: Input type (MPSFloatType) and weight type (MPSHalfType) should be the same

Additional information

I tried several times to re do it but it keeps on getting that error

humam-homo avatar Jan 28 '23 14:01 humam-homo

I managed to add --no-half option to avoid this issue.

julianko13 avatar Feb 09 '23 14:02 julianko13

@julianko13 how did you do this if you don't mind me asking? I'm not a programmer so I'm not familiar with how to do this. I got the same error this morning when trying to run an animation. Thank you!

threadpunk avatar Mar 07 '23 14:03 threadpunk