Open LouisShark opened 4 months ago
came here wondering the same thing, incredulous that nobody has gotten it working already even though it's been out for so long
I guess I've been too online, since it's only been out for one day
I did some changes as workaround to get the Step 1 and Step 2 running on my Mac with M1 with a pretty good performance.
What I did:
1) Cloned main
2) On gradio_app.py changed rng = torch.Generator(device=memory_management.gpu).manual_seed(int(seed))
to use device=memory_management.mps
3) On memory_management.py I...
3.1) replaced cpu = torch.device('cpu')
with mps = torch.device('mps')
3.2) changed torch.zeros((1, 1)).to(gpu, torch.float32)
to use mps
instead of gpu
3.3) modified load_models_to_gpu
function to:
def load_models_to_gpu(models):
global models_in_gpu
if not isinstance(models, (tuple, list)):
models = [models]
models_to_remain = [m for m in set(models) if m in models_in_gpu]
models_to_load = [m for m in set(models) if m not in models_in_gpu]
models_to_unload = [m for m in set(models_in_gpu) if m not in models_to_remain]
if not high_vram:
for m in models_to_unload:
with movable_bnb_model(m):
m.to(mps)
print('Unload to MPS:', m.__class__.__name__)
models_in_gpu = models_to_remain
for m in models:
m.to(mps) #
print('Load to MPS:', m.__class__.__name__)
models_in_gpu = list(set(models_in_gpu + models))
torch.cuda.empty_cache()
return
I know step 3.3 is quite dirty, but it does the trick for me.
+1