From 29bd41d453cc8404b7183af685cdd4b952e96435 Mon Sep 17 00:00:00 2001 From: oobabooga <112222186+oobabooga@users.noreply.github.com> Date: Thu, 23 Mar 2023 01:05:13 -0300 Subject: [PATCH] Fix LoRA in CPU mode --- modules/LoRA.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/modules/LoRA.py b/modules/LoRA.py index 20850338..0a2aaa7d 100644 --- a/modules/LoRA.py +++ b/modules/LoRA.py @@ -18,10 +18,10 @@ def add_lora_to_model(lora_name): params = {} if shared.args.load_in_8bit: params['device_map'] = {'': 0} - else: + elif not shared.args.cpu: params['device_map'] = 'auto' params['dtype'] = shared.model.dtype 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()