|
@@ -112,12 +112,13 @@ def load_model(model_name):
|
|
|
model = load_quant(path_to_model, Path(f"models/{pt_model}"), 4)
|
|
model = load_quant(path_to_model, Path(f"models/{pt_model}"), 4)
|
|
|
|
|
|
|
|
if shared.args.gpu_memory:
|
|
if shared.args.gpu_memory:
|
|
|
|
|
+ import accelerate
|
|
|
|
|
+
|
|
|
max_memory = {}
|
|
max_memory = {}
|
|
|
for i in range(len(shared.args.gpu_memory)):
|
|
for i in range(len(shared.args.gpu_memory)):
|
|
|
max_memory[i] = f"{shared.args.gpu_memory[i]}GiB"
|
|
max_memory[i] = f"{shared.args.gpu_memory[i]}GiB"
|
|
|
max_memory['cpu'] = f"{shared.args.cpu_memory or '99'}GiB"
|
|
max_memory['cpu'] = f"{shared.args.cpu_memory or '99'}GiB"
|
|
|
|
|
|
|
|
- import accelerate
|
|
|
|
|
device_map = accelerate.infer_auto_device_map(model, max_memory=max_memory, no_split_module_classes=["LLaMADecoderLayer"])
|
|
device_map = accelerate.infer_auto_device_map(model, max_memory=max_memory, no_split_module_classes=["LLaMADecoderLayer"])
|
|
|
model = accelerate.dispatch_model(model, device_map=device_map)
|
|
model = accelerate.dispatch_model(model, device_map=device_map)
|
|
|
else:
|
|
else:
|