d8ahazard / sd_dreambooth_extension

Other
1.86k stars 283 forks source link

[Bug]: `shutil.rmtree(tmp_dir)` throws PermissionError in `save_weights` #1260

Closed RooseveltAdvisors closed 1 year ago

RooseveltAdvisors commented 1 year ago

Is there an existing issue for this?

What happened?

At line 969 of train_dreambooth.py, an PermissionError occurs while attempting to delete the temporary file.

I haven't encountered any issues on Linux, but it appears that this problem is specific to Windows.

Steps to reproduce the problem

  1. Go to Dreambooth, and select a model in the left panel
  2. Press Train

Commit and libraries

Python 3.10.8 (tags/v3.10.8:aaaf517, Oct 11 2022, 16:50:30) [MSC v.1933 64 bit (AMD64)] Version: v1.3.1 Commit hash: b6af0a3809ea869fb180633f9affcae4b199ffcf Installing requirements

Stop Motion CN - Running Preload Set Gradio Queue: True If submitting an issue on github, please provide the full startup log for debugging purposes.

Initializing Dreambooth Dreambooth revision: b396af26b7906aa82a29d8847e756396cb2c28fb Successfully installed accelerate-0.19.0 fastapi-0.94.1 gitpython-3.1.31 transformers-4.29.2

Does your project take forever to startup? Repetitive dependency installation may be the reason. Automatic1111's base project sets strict requirements on outdated dependencies. If an extension is using a newer version, the dependency is uninstalled and reinstalled twice every startup.

[+] xformers version 0.0.20 installed. [+] torch version 2.0.1+cu118 installed. [+] torchvision version 0.15.2+cu118 installed. [+] accelerate version 0.19.0 installed. [+] diffusers version 0.16.1 installed. [+] transformers version 4.29.2 installed. [+] bitsandbytes version 0.35.4 installed.

Launching Web UI with arguments: --theme dark --xformers --opt-channelslast --api --autolaunch Stop Motion CN - Running Preload Set Gradio Queue: True Additional Network extension not installed, Only hijack built-in lora LoCon Extension hijack built-in lora successfully [AddNet] Updating model hashes...

[AddNet] Updating model hashes...

2023-06-03 19:22:08,423 - ControlNet - INFO - ControlNet v1.1.214 2023-06-03 19:22:08,500 - ControlNet - INFO - ControlNet v1.1.214

Command Line Arguments

No

Console logs

File "C:\sd-web-ui\extensions\sd_dreambooth_extension\dreambooth\ui_functions.py", line 729, in start_training
    result = main(class_gen_method=class_gen_method)
  File "C:\sd-web-ui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 1546, in main
    return inner_loop()
  File "C:\sd-web-ui\extensions\sd_dreambooth_extension\dreambooth\memory.py", line 119, in decorator
    return function(batch_size, grad_size, prof, *args, **kwargs)
  File "C:\sd-web-ui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 1500, in inner_loop
    check_save(True)
  File "C:\sd-web-ui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 794, in check_save
    save_weights(
  File "C:\sd-web-ui\extensions\sd_dreambooth_extension\dreambooth\train_dreambooth.py", line 1066, in save_weights
    shutil.rmtree(tmp_dir)
  File "shutil.py", line 749, in rmtree
  File "shutil.py", line 614, in _rmtree_unsafe
  File "shutil.py", line 619, in _rmtree_unsafe
  File "shutil.py", line 617, in _rmtree_unsafe
PermissionError: [WinError 5] Access is denied: 'C:\\Users\\sd\\AppData\\Local\\Temp\\tmpngtzi41b\\text_encoder\\model.safetensors'

Additional information

No response

github-actions[bot] commented 1 year 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