add no_split_module_classes to prevent tensor split error

This commit is contained in:
deepdiffuser 2023-03-10 05:30:47 -08:00
parent ab47044459
commit 9fbd60bf22

View File

@ -118,7 +118,7 @@ def load_model(model_name):
max_memory['cpu'] = f"{shared.args.cpu_memory or '99'}GiB" max_memory['cpu'] = f"{shared.args.cpu_memory or '99'}GiB"
import accelerate import accelerate
device_map = accelerate.infer_auto_device_map(model, max_memory=max_memory) 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:
model = model.to(torch.device('cuda:0')) model = model.to(torch.device('cuda:0'))