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

[Bug]: C: drive storage leak

Open abver090 opened this issue 1 year ago • 13 comments

Is there an existing issue for this?

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

What happened?

For some reason the C: drive keeps filling up even though my Stable Diffusion installation is in the D: drive. I have a feeling that it will keep filling up the C: drive until it can't contain any more space. It appears to be a storage leak. image

Steps to reproduce the problem

Just start the installer first try

What should have happened?

Should have stopped at a certain storage number.

Commit where the problem happens

cmd

What platforms do you use to access the UI ?

No response

What browsers do you use to access the UI ?

No response

Command Line Arguments

No

List of extensions

No

Console logs

N/A

Additional information

I had 20 GB of C: drive memory before it began to drain rapidly. It even reached 10.5 GB

abver090 avatar Feb 02 '23 11:02 abver090

Probably unrelated to stable-diffusion-webui. Maybe your Windows downloaded an update.

gabsoftware avatar Feb 02 '23 11:02 gabsoftware

Probably unrelated to stable-diffusion-webui. Maybe your Windows downloaded an update.

No. The space keeps rising only whenever I start the install. It happens every single time and there is no update going on parallel to the install.

abver090 avatar Feb 02 '23 13:02 abver090

The cause of space loss on C:\ drive is pip installation cache located at %USERPROFILE%\AppData\Local\pip — mine is currently at 21.89 GB.

In other words, it's not a bug — it's a feature.

It is possible to change the cache location by using --cache-dir <dir> command line option when running pip, it would be nice if this was added as a configurable option somewhere.

levicki avatar Feb 02 '23 13:02 levicki

How to run pip?

abver090 avatar Feb 02 '23 14:02 abver090

Also, I've just tried to change directory, but the command for changing the cache directory using --cache-dir <dir> does not work

abver090 avatar Feb 02 '23 14:02 abver090

  • First find the large files and folders either manually by checking each folder properties or by using a software like WinDirStat
  • If that's pip cache and you don't need it anymore, you can clean the cache by using pip cache purge command.

ataa avatar Feb 02 '23 16:02 ataa

@abver090

  1. You are not supposed to run pip manually — it is run by scripts in the repository to install various packages and dependencies.
  2. Just running pip --cache-dir D:\pip won't work because that's not how the command is used.

TL;DR — you would have to change all calls to pip command in every python script in the repository and add --cache-dir D:\pip at the end after all other parameters if you wanted pip not to use your C:\ drive.

You seem like someone who is not well versed in development tools and command prompts so perhaps the best you can do is submit a feature request to make pip cache location configurable.

levicki avatar Feb 02 '23 16:02 levicki

This is likely related to #3278. There's an issue where temp versions of generations are left in your temp folder and not properly cleaned. There was a change that suggested it'd try to fix this, but as far as I could see all it did was make it stop making subfolders per WebUI run for the temp files - now they all dump in the base of the temp folder. You might need to manually set a temp folder for the cleanup to work correctly.

In the meantime, check %temp% for PNG files and clear all the ones that are clearly AI generations.

MegaScience avatar Feb 02 '23 17:02 MegaScience

This is likely related to https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/3278. There's an issue where temp versions of generations are left in your temp folder and not properly cleaned. There was a change that suggested it'd try to fix this, but as far as I could see all it did was make it stop making subfolders per WebUI run for the temp files - now they all dump in the base of the temp folder. You might need to manually set a temp folder for the cleanup to work correctly. In the meantime, check %temp% for PNG files and clear all the ones that are clearly AI generations.

This is not related, the space only start filling up during generation, not as OP said during installation. This is 99% a pip cache issue.

aliencaocao avatar Feb 03 '23 03:02 aliencaocao

@abver090 go to C:\Users\YOUR-USERNAME\AppData on Local folder there is a folder "pip". It's the cache folder. Copy this entire folder to another disk with enough free space. go to C:\Users\YOUR-USERNAME\AppData\Roaming\pip or if there's no pip folder on Roaming, create it. on ..\Roaming\pip create a .txt file and rename to pip.ini edit pip.ini with notepad and add this code:

[global] no-cache-dir = false download-cache = X:\NEW_PIP_DRIVE\pip\cache

X:\NEW_PIP_DRIVE\pip\cache - replace this by the new path on your system Then you can delete original pip on C:\ because all installations will be use the path of pip.ini This works for me. My SD still running and installing stuff without errors.

dinhosms avatar Feb 05 '23 10:02 dinhosms

C: Drive is still filling up, @dinhosms. It appears as though the buildup is specific to the C:\Users\NAME\AppData\Local\Temp\pip-unpack-w85244jm folder. That solution didn't work.

abver090 avatar Feb 05 '23 14:02 abver090

C: Drive is still filling up, @dinhosms. It appears as though the buildup is specific to the C:\Users\NAME\AppData\Local\Temp\pip-unpack-w85244jm folder. That solution didn't work.

You can try to change the environment variable TEMP to other free directories on the disk. This is how I solve it

shirenhu avatar Feb 20 '23 10:02 shirenhu

I found another solution. Create a hard link to the folder you are going to use. For this you first need to see which folders in appdata are taking up space. I've done this for almost every folder. I closed all open programs, including those in the tray. Then I created a list of all folders via cmd prompt. Then I copied all the folders to another HDD. In appdata, I renamed the folders including an x at the beginning of the name just so I would know which ones weren't in use. Windows does not let you change the name of the ones being used. Once that was done, I removed the folders that I couldn't rename from the list. With the updated list, I created a file in excel to assemble a structure that would create several lines with the following command:

mklink /J "C:\Users\myusername\AppData\Local\Folder1" "X:\Program Files\Local\Folder1"

In the first column I put the command [mklink /J ], in the second column I put [ " ] because it is necessary to create the link of folders that contain spaces in the name. In the third column I put the appdata address [C:\Users\myusername\AppData\Local\Folder1]. In the fourth column I put [ " " ]. In the fifth column I put the address where I copied the folders [X:\Program Files\Local\Folder1]. And I ended the sixth column with [ " ]. I did this for all folders, one on each line. The result should be a sequence of lines with this command, just changing the folder names. After that, I exported as .txt. I opened the .txt file in notepad and replaced the quotation marks because it comes out with a tab space and I don't know if it gets in the way or not, but I preferred not to risk it. Fixed tabbing problem, I saved with .bat. Then it was just running bat as administrator and all the links were created at once. After testing with some softwares that had folders in appdata to see if everything was ok, I deleted all the folders that I had renamed. Freed up almost 40gb of space, for a 256gb SSD this was my salvation

dinhosms avatar Feb 20 '23 22:02 dinhosms

You can set the XDG_CACHE_DIR and XDG_CACHE_HOME environment variables to set e.g. where the Pip and Huggingface caches reside.

akx avatar Jun 18 '23 16:06 akx