Fix issue that left text encoder on gpu after caching text embeddings.
This commit is contained in:
1 parent
7b94dc5d8d
commit
8cf43dd2cc
1 file changed
+10
@@ -2254,6 +2254,16 @@ class BaseSDTrainProcess(BaseTrainProcess):
|
||||
pool_datasets=self.train_config.pool_datasets,
|
||||
)
|
||||
|
||||
# a fresh text-embedding cache leaves the text encoder on the gpu (the
|
||||
# datasets don't restore placement: that would bounce it per dataset).
|
||||
# Park it once here, before accelerator.prepare brings the unet up.
|
||||
if (
|
||||
self.is_caching_text_embeddings
|
||||
and self.model_config.low_vram
|
||||
and self.sd.text_encoder is not None
|
||||
):
|
||||
self.sd.text_encoder_to('cpu')
|
||||
|
||||
flush()
|
||||
self.last_save_step = self.step_num
|
||||
### HOOK ###
|
||||
|
||||
Reference in new issue
Block a user