mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
proposed fix to work on mps systems
This commit is contained in:
parent
b537e92789
commit
aa6aa68753
@ -195,15 +195,17 @@ class ModelCache(object):
|
|||||||
torch.cuda.empty_cache()
|
torch.cuda.empty_cache()
|
||||||
|
|
||||||
def _model_to_cpu(self,model):
|
def _model_to_cpu(self,model):
|
||||||
if self._has_cuda():
|
if self.device != 'cpu':
|
||||||
model.cond_stage_model.device = 'cpu'
|
model.cond_stage_model.device = 'cpu'
|
||||||
model.first_stage_model.to('cpu')
|
model.first_stage_model.to('cpu')
|
||||||
model.cond_stage_model.to('cpu')
|
model.cond_stage_model.to('cpu')
|
||||||
model.model.to('cpu')
|
model.model.to('cpu')
|
||||||
return model.to('cpu')
|
return model.to('cpu')
|
||||||
|
else:
|
||||||
|
return model
|
||||||
|
|
||||||
def _model_from_cpu(self,model):
|
def _model_from_cpu(self,model):
|
||||||
if self._has_cuda():
|
if self.device != 'cpu':
|
||||||
model.to(self.device)
|
model.to(self.device)
|
||||||
model.first_stage_model.to(self.device)
|
model.first_stage_model.to(self.device)
|
||||||
model.cond_stage_model.to(self.device)
|
model.cond_stage_model.to(self.device)
|
||||||
|
@ -154,6 +154,7 @@ def main_loop(gen, opt, infile):
|
|||||||
elif subcommand.startswith('switch'):
|
elif subcommand.startswith('switch'):
|
||||||
model_name = command.replace('!switch ','',1)
|
model_name = command.replace('!switch ','',1)
|
||||||
gen.set_model(model_name)
|
gen.set_model(model_name)
|
||||||
|
completer.add_history(command)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
elif subcommand.startswith('models'):
|
elif subcommand.startswith('models'):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user