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

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument index in method wrapper__index_select) #20

Closed T0b1maru closed 1 year ago

T0b1maru commented 1 year ago

So it seems to always fail when trying to run on gpu --device cuda or --device cuda:0

Traceback (most recent call last):
  File "/home/kharion/Projects/Merge-Stable-Diffusion-models-without-distortion/SD_rebasin_merge.py", line 67, in <module>
    first_permutation, y = weight_matching(permutation_spec, flatten_params(model_a), theta_0, usefp16=args.usefp16)
  File "/home/kharion/Projects/Merge-Stable-Diffusion-models-without-distortion/weight_matching.py", line 846, in weight_matching
    w_b = get_permuted_param(ps, perm, wk, params_b, except_axis=axis).half()
  File "/home/kharion/Projects/Merge-Stable-Diffusion-models-without-distortion/weight_matching.py", line 778, in get_permuted_param
    w = torch.index_select(w, axis, perm[p].int())
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! (when checking argument for argument index in method wrapper__index_select)
ogkalu2 commented 1 year ago

You can't run gpu only. The code already uses the gpu to run the calculations it can so just leave the default as is and it'll use your gpu

T0b1maru commented 1 year ago

Alright thanks for clarification. It's mighty confusing having the --device then though. But i'll close it then. Thanks again.