Make sure device_config() still works with all layers on CPU

This commit is contained in:
Gnome Ann 2021-11-14 18:46:00 -05:00
parent 80aee07816
commit 805cb0c8b9
1 changed files with 2 additions and 2 deletions

View File

@ -273,9 +273,9 @@ def device_config(model):
device_list(n_layers) device_list(n_layers)
# If all layers are on the same device, use the old GPU generation mode # If all layers are on the same device, use the old GPU generation mode
while(breakmodel.gpu_layers[-1] == 0): while(len(breakmodel.gpu_layers) and breakmodel.gpu_layers[-1] == 0):
breakmodel.gpu_layers.pop() breakmodel.gpu_layers.pop()
if(breakmodel.gpu_layers[-1] in (-1, model.config.num_layers)): if(len(breakmodel.gpu_layers) and breakmodel.gpu_layers[-1] in (-1, model.config.num_layers)):
vars.breakmodel = False vars.breakmodel = False
vars.usegpu = True vars.usegpu = True
model = model.to(len(breakmodel.gpu_layers)-1) model = model.to(len(breakmodel.gpu_layers)-1)