thygate / stable-diffusion-webui-depthmap-script

High Resolution Depth Maps for Stable Diffusion WebUI
MIT License
1.71k stars 159 forks source link

Combatting memory leaks #315

Open semjon00 opened 1 year ago

semjon00 commented 1 year ago

Known VRAM leaks:

  1. If generating OOMs, ironically, it does not free memory (standalone mode).
  2. Generating a lot of images (with zoedepth?) maybe creates OOM.

Known RAM leaks:

  1. Batching from directory creates all the PIL image objects at once. Weird...
T0biasCZe commented 1 year ago

Batching from directory loads all the images at once. Not ideal.

its very not ideal, because it can hit C runtime max open files limit And when you have just 1 more file than 8192, it throws OSError: [Errno 24] Too many open files: './models/leres/res101.pth'error Which is very annoying when trying to do a whole video, since you have to convert it in like 4 rus...

semjon00 commented 1 year ago

@T0biasCZe Please try out the new Single Video mode :) By the way, 8192 is a lot of files O_O This can be patched, I will look into it in the following week or two.

T0biasCZe commented 1 year ago

By the way, 8192 is a lot of files O_O

Wellllll, at 24fps thats just 5 minutes 41seconds :D and considering it runs at 1.5files/s (with res101) it doesnt take that long

T0biasCZe commented 1 year ago

Also, with the video mode, if the conversion stops mid generation (for example error or something), the already generated images will propably be lost and it will be uncontinuable (which is issue for 20 minute vids...) Unless it could be made to output the converted frames into jpegs instead of back into another video πŸ€”And then when converting the frames, it would check if the frame already exists in the folder and potencially skip it πŸ€”

T0biasCZe commented 1 year ago

Yeah like expected, mid conversion threw error, video gon πŸ˜„ image

semjon00 commented 1 year ago

Unless it could be made to output the converted frames into jpegs instead of back into another video thinkingAnd then when converting the frames, it would check if the frame already exists in the folder and potencially skip it thinking

This would make it really complicated. I will think about this, maybe there will be a solution in the future.

@T0biasCZe This is not a memory issue (the video was done except saving video from ready frames). ~Please ensure that the plugin is properly installed. For whatever reason backbone.py was not properly updated. How did you install the update?~ Ooh! Found an error! Thanks!

semjon00 commented 1 year ago

@T0biasCZe Please update the extension and try again - please let me know if everything works now.

T0biasCZe commented 1 year ago

the video was done except saving video from ready frames

so it does save into jpegs first? πŸ™ƒ

semjon00 commented 1 year ago

No, no. I meant that the images that the video would consist of were already created - 16-bit grayscale png-s for depthmaps and/or 24-bit images for colorvideos. These images are stored in RAM and not saved. What was left is to bundle them into a video. Please try again (after updating the extension), it should just work.

T0biasCZe commented 1 year ago

Jpeg/Png doesnt matter. And i meant the already processed and finished images, not the raw images from the input video...

sooo... It should be possible to make the processing continue in case it for any reasons stopped during the conversion πŸ™ƒ

T0biasCZe commented 1 year ago

And yeah the new update forks.... (but that wont help with other mid process interuptions)

semjon00 commented 1 year ago

Please send the stacktrace... You know, otherwise I can't help.

semjon00 commented 1 year ago

sooo... It should be possible to make the processing continue in case it for any reasons stopped during the conversion upside_down_face

Yep, a good idea, but not a priority right now. There are some more pressing issues at the moment... If you know how to fix it, you could create a MR, I would happily review and merge :+1:

T0biasCZe commented 1 year ago

Please send the stacktrace... You know, otherwise I can't help.

i didnt mean any specific error right now, but I meant overall if it stopped later, for example system running out of ram ehm memory laks, windows crashing, etc. that would make the conversion get interrupted mid run

semjon00 commented 1 year ago

@T0biasCZe Sorry, misread your message

SauChi666 commented 11 months ago

Pls do output files one at a time, not all at the very end,,, so when there is an error I do not have to start all over, I can continue with the files that aare not processed... it was working like that before... I am having problems with large files...