TheLastBen / fast-stable-diffusion

fast-stable-diffusion + DreamBooth
MIT License
7.5k stars 1.31k forks source link

huge ram issue when changing models #1567

Open remybonnav opened 1 year ago

remybonnav commented 1 year ago

most of the time when you want to change a model, the max RAM memory is reached. even if loading a 2gb model. Why is there so much loaded in ra? This is a huge issue

TheLastBen commented 1 year ago

It's a known bug that the google colab team hasn't been able to fix yet https://github.com/googlecolab/colabtools/issues/3363

StiffPvtParts commented 1 year ago

Man, hope they fix it soon. I've been having the issue as well.

@TheLastBen thanks for letting us know.

Omenizer commented 1 year ago

same here, 100% crash on model load :(

Omenizer commented 1 year ago

uff they closed the colab issue 😭

TheLastBen commented 1 year ago

try with the latest colab, hopefully this commit will fix it https://github.com/TheLastBen/fast-stable-diffusion/commit/67145d8e54c9128f3981ddc763282f6485ab47e9

remybonnav commented 1 year ago

It works now, no more RAM problem when changing models. but To load, it takes 60sec for a 2GB model and 256 sec for a 7GB model.

TheLastBen commented 1 year ago

the long loading is caused in colab by extensions, if you have many of them installed they cause a delay

remybonnav commented 1 year ago

I don't know because I just tested it without login my google drive so it was a fresh new install on the google colab kernel without extension installed.

Omenizer commented 1 year ago

I have no extensions and loading is super slow now. Anything I can do?

TheLastBen commented 1 year ago

for a 2GB model ?

Omenizer commented 1 year ago

Yes, 187 seconds

Omenizer commented 1 year ago

Still got RAM issues/crashes too, basically after every merge it will ^C after trying to load the new model :(

remybonnav commented 1 year ago

Actually, it came back to normal loading time for me (using google drive).

TheLastBen commented 1 year ago

Soon there will be alternative notebooks for different cloud providers.

remybonnav commented 1 year ago

Kaggle? :)

TheLastBen commented 1 year ago

Paperspace and Runpod, Kaggle probably won't allow thousands of users using 2xT4 for free.

Daviljoe193 commented 1 year ago

I've only just come up with this (Honestly repulsive) workaround, which involves rolling back a few specific dependancies. It's not pretty, at all, and I don't even know how much of it is needed, but if you add the following cell to the notebook, and run it at least once (Preferably first), the memory behavior seems to go back to how it used to be.

!wget http://launchpadlibrarian.net/367274644/libgoogle-perftools-dev_2.5-2.2ubuntu3_amd64.deb
!wget https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/google-perftools_2.5-2.2ubuntu3_all.deb
!wget https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libtcmalloc-minimal4_2.5-2.2ubuntu3_amd64.deb
!wget https://launchpad.net/ubuntu/+source/google-perftools/2.5-2.2ubuntu3/+build/14795286/+files/libgoogle-perftools4_2.5-2.2ubuntu3_amd64.deb
!apt install -qq libunwind8-dev
!dpkg -i *.deb
%env LD_PRELOAD=libtcmalloc.so
TheLastBen commented 1 year ago

I'll try that thanks