Fix LoRA in CPU mode

This commit is contained in:
oobabooga 2023-03-23 01:05:13 -03:00 committed by GitHub
parent eac27f4f55
commit 29bd41d453
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -18,10 +18,10 @@ def add_lora_to_model(lora_name):
params = {} params = {}
if shared.args.load_in_8bit: if shared.args.load_in_8bit:
params['device_map'] = {'': 0} params['device_map'] = {'': 0}
else: elif not shared.args.cpu:
params['device_map'] = 'auto' params['device_map'] = 'auto'
params['dtype'] = shared.model.dtype params['dtype'] = shared.model.dtype
shared.model = PeftModel.from_pretrained(shared.model, Path(f"loras/{lora_name}"), **params) shared.model = PeftModel.from_pretrained(shared.model, Path(f"loras/{lora_name}"), **params)
if not shared.args.load_in_8bit: if not shared.args.load_in_8bit and not shared.args.cpu:
shared.model.half() shared.model.half()