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

huge ram issue when changing models

Open remybonnav opened this issue 2 years ago • 18 comments

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

remybonnav avatar Feb 08 '23 21:02 remybonnav

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

TheLastBen avatar Feb 08 '23 23:02 TheLastBen

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

@TheLastBen thanks for letting us know.

StiffPvtParts avatar Feb 08 '23 23:02 StiffPvtParts

same here, 100% crash on model load :(

Omenizer avatar Feb 09 '23 12:02 Omenizer

uff they closed the colab issue 😭

Omenizer avatar Feb 09 '23 20:02 Omenizer

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

TheLastBen avatar Feb 10 '23 09:02 TheLastBen

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.

remybonnav avatar Feb 10 '23 13:02 remybonnav

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

TheLastBen avatar Feb 10 '23 17:02 TheLastBen

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.

remybonnav avatar Feb 10 '23 17:02 remybonnav

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

Omenizer avatar Feb 12 '23 11:02 Omenizer

for a 2GB model ?

TheLastBen avatar Feb 12 '23 18:02 TheLastBen

Yes, 187 seconds

Omenizer avatar Feb 12 '23 18:02 Omenizer

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

Omenizer avatar Feb 12 '23 22:02 Omenizer

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

remybonnav avatar Feb 13 '23 10:02 remybonnav

Soon there will be alternative notebooks for different cloud providers.

TheLastBen avatar Feb 13 '23 12:02 TheLastBen

Kaggle? :)

remybonnav avatar Feb 13 '23 12:02 remybonnav

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

TheLastBen avatar Feb 14 '23 12:02 TheLastBen

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

Daviljoe193 avatar Feb 16 '23 00:02 Daviljoe193

I'll try that thanks

TheLastBen avatar Feb 16 '23 11:02 TheLastBen