a2569875 / stable-diffusion-webui-composable-lora

This extension replaces the built-in LoRA forward procedure.
GNU Affero General Public License v3.0
155 stars 14 forks source link

[Fix for Mac] Push input and weights to MPS device for M1/M2 devices #31

Open SenshiSentou opened 6 months ago

SenshiSentou commented 6 months ago

This fixes the RuntimeError: Placeholder storage has not been allocated on MPS device! I was getting on my M1 Macbook Pro. I was still occasionally getting an error relating to the bias format seemingly at random (the best kind of error is an unpredictable one), but adding --no-half to my launch params seems to have fixed that.

This was my first time actually delving into torch code, so hopefully this is the correct approach?

Tested on A1111 v1.6.0-2-g4afaaf8a, python: 3.10.13, torch: 2.3.0.dev20231219, checkpoint: a3d7311d85

EDIT: Seems I forgot to commit the rename before pushing... oops ^.^; please rename self_weight_cuda to self_weight_mps :p

SenshiSentou commented 6 months ago

As a sidenote, both this and the CUDA check code should probably be refactored, but I wanted to keep this PR as straight-forward as possible

SenshiSentou commented 6 months ago

Aaand after generating a bunch of images successfully, it started complaining about the bias type again. I'm not sure where that lives, so I'll have to look into that another time :(