Merge branch 'oobabooga:main' into lora-and-model-dir

This commit is contained in:
catalpaaa 2023-03-25 01:28:33 -07:00 committed by GitHub
commit f740ee558c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 9 deletions

View file

@ -1,5 +1,7 @@
from pathlib import Path
import torch
import modules.shared as shared
from modules.models import load_model
from modules.text_generation import clear_torch_cache
@ -34,4 +36,8 @@ def add_lora_to_model(lora_name):
if not shared.args.load_in_8bit and not shared.args.cpu:
shared.model.half()
if not hasattr(shared.model, "hf_device_map"):
shared.model.cuda()
if torch.has_mps:
device = torch.device('mps')
shared.model = shared.model.to(device)
else:
shared.model = shared.model.cuda()