Repository: stable-diffusion-webui
Issue: [Bug]: Error training embedding
Labels: bug-report

### Checklist

- [ ] The issue exists after disabling all extensions
- [ ] The issue exists on a clean installation of webui
- [ ] The issue is caused by an extension, but I believe it is caused by a bug in the webui
- [ ] The issue exists in the current version of the webui
- [ ] The issue has not been reported before recently
- [ ] The issue has been reported before but has not been fixed yet

### What happened?

```
Calculating sha256 for D:\stable-diffusion-webui\embeddings\n0n1pp1e5.pt: 5ab059d44f700da25700191f6762d483468c57739982625e860a7546d2c83663
Training at rate of 0.005 until step 100000
Preparing dataset...
100%|████████████████████████████████████████████████████████████████████████████████| 209/209 [00:08<00:00, 23.73it/s]
  0%|                                                                                       | 0/100000 [00:00<?, ?it/s]*** Error training embedding
    Traceback (most recent call last):
      File "D:\stable-diffusion-webui\modules\textual_inversion\textual_inversion.py", line 551, in train_embedding
        loss = shared.sd_model.forward(x, cond)[0] / gradient_step
      File "D:\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py", line 846, in forward
        return self.p_losses(x, c, t, *args, **kwargs)
      File "D:\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py", line 886, in p_losses
        model_output = self.apply_model(x_noisy, t, cond)
      File "D:\stable-diffusion-webui\modules\sd_hijack_utils.py", line 22, in <lambda>
        setattr(resolved_obj, func_path[-1], lambda *args, **kwargs: self(*args, **kwargs))
      File "D:\stable-diffusion-webui\modules\sd_hijack_utils.py", line 34, in __call__
        return self.__sub_func(self.__orig_func, *args, **kwargs)
      File "D:\stable-diffusion-webui\modules\sd_hijack_unet.py", line 50, in apply_model
        result = orig_func(self, x_noisy.to(devices.dtype_unet), t.to(devices.dtype_unet), cond, **kwargs)
      File "D:\stable-diffusion-webui\modules\sd_hijack_utils.py", line 22, in <lambda>
        setattr(resolved_obj, func_path[-1], lambda *args, **kwargs: self(*args, **kwargs))
      File "D:\stable-diffusion-webui\modules\sd_hijack_utils.py", line 36, in __call__
        return self.__orig_func(*args, **kwargs)
      File "D:\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py", line 858, in apply_model
        x_recon = self.model(x_noisy, t, **cond)
      File "D:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\models\diffusion\ddpm.py", line 1335, in forward
        out = self.diffusion_model(x, t, context=cc)
      File "D:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\stable-diffusion-webui\modules\sd_unet.py", line 91, in UNetModel_forward
        return original_forward(self, x, timesteps, context, *args, **kwargs)
      File "D:\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\ldm\modules\diffusionmodules\openaimodel.py", line 789, in forward
        emb = self.time_embed(t_emb)
      File "D:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\container.py", line 215, in forward
        input = module(input)
      File "D:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1518, in _wrapped_call_impl
        return self._call_impl(*args, **kwargs)
      File "D:\stable-diffusion-webui\venv\lib\site-packages\torch\nn\modules\module.py", line 1527, in _call_impl
        return forward_call(*args, **kwargs)
      File "D:\stable-diffusion-webui\extensions-builtin\Lora\networks.py", line 582, in network_Linear_forward
        network_apply_weights(self)
      File "D:\stable-diffusion-webui\extensions-builtin\Lora\networks.py", line 454, in network_apply_weights
        network_restore_weights_from_backup(self)
      File "D:\stable-diffusion-webui\extensions-builtin\Lora\networks.py", line 403, in network_restore_weights_from_backup
        restore_weights_backup(self, 'weight', weights_backup)
      File "D:\stable-diffusion-webui\extensions-builtin\Lora\networks.py", line 388, in restore_weights_backup
        getattr(obj, field).copy_(weight)
    RuntimeError: a leaf Variable that requires grad is being used in an in-place operation.

---
Applying attention optimization: xformers... done.
```

### Steps to reproduce the problem


![image](https://github.com/user-attachments/assets/f87312e6-1575-4cac-91b1-0b86e84610b3)


![image](https://github.com/user-attachments/assets/9126817c-91f0-4910-b6ba-490956af57e2)



### What should have happened?

.

### What browsers do you use to access the UI ?

Mozilla Firefox

### Sysinfo

[sysinfo-2024-11-01-08-05.json](https://github.com/user-attachments/files/17597521/sysinfo-2024-11-01-08-05.json)


### Console logs

```Shell
.
```


### Additional information

[n0n1pp1e5.zip](https://github.com/user-attachments/files/17597574/n0n1pp1e5.zip)
[n0n1pp1e5.z01.zip](https://github.com/user-attachments/files/17597579/n0n1pp1e5.z01.zip) <== rename as `n0n1pp1e5.z01`