ogkalu2 / Merge-Stable-Diffusion-models-without-distortion

Adaptation of the merging method described in the paper - Git Re-Basin: Merging Models modulo Permutation Symmetries (https://arxiv.org/abs/2209.04836) for Stable Diffusion
MIT License
139 stars 21 forks source link

Can't use in colab? #14

Open User1231300 opened 1 year ago

User1231300 commented 1 year ago

I installed torch==1.11.0

when trying to merge i get this

Using half precision

---------------------
     ITERATION 1
---------------------

new alpha = 0.05

FINDING PERMUTATIONS P_bg337: -0.5 P_bg324: -0.5 P_bg358: -0.125 P_bg324: 0.5 0.42857142857142855

---------------------
     ITERATION 2
---------------------

new alpha = 0.05263157894736836

FINDING PERMUTATIONS P_bg358: 0.0625 P_bg337: 1.0 ^C

How to fix?

ogkalu2 commented 1 year ago

Hi that looks like you ran out of memory. Try the new commit. It's optimized. See if it works now

User1231300 commented 1 year ago

It's not working. Can you add a clear list of requirements?

ogkalu2 commented 1 year ago

Really the only requirement is

pip install torch==1.11.0+cu113 torchvision==0.12.0+cu113 torchaudio==0.11.0 --extra-index-url https://download.pytorch.org/whl/cu113

R-N commented 1 year ago

I'm having the same issue on Google Colab, but worse. It crashes right away at first iteration.

/content/merger
Using half precision

    ---------------------
         ITERATION 1
    ---------------------

new alpha = 0.045

^C

Code:

!pip install pytorch-lightning torch==1.11.0+cu113 torchvision==0.12.0+cu113 

!git clone https://github.com/ogkalu2/Merge-Stable-Diffusion-models-without-distortion merger
%cd /content/merger

#download models from hf
!curl ...

model_a_path = "novelai.ckpt"
model_b_path = "sd_1.5.ckpt"
output_name = f"NAI_f222_0.45ws.ckpt"
alpha = 0.45

%cd /content/merger
!python SD_rebasin_merge.py --model_a {model_a_path} --model_b {model_b_path} --output {output_name} --alpha {alpha}

They're both 4GB checkpoints (fp32). Here's RAM usage: image

By the way it seems to need one more requirement: pytorch-lightning EDIT: Nvm, it's required by the checkpoint pickle

Anyway, I'll try using GPU

R-N commented 1 year ago

I'm getting an error with GPU but I think it's progressing. I guess it was indeed RAM issue.