Add gc.collect()

This commit is contained in:
Edresson Casanova 2023-12-01 15:37:09 -03:00
parent 490af290d3
commit e9a2c0606a
2 changed files with 6 additions and 2 deletions

View File

@ -1,4 +1,5 @@
import os
import gc
import torchaudio
import pandas
from faster_whisper import WhisperModel
@ -152,7 +153,8 @@ def format_audio_list(audio_files, target_language="en", out_path=None, buffer=0
df_eval = df_eval.sort_values('audio_file')
df_eval.to_csv(eval_metadata_path, sep="|", index=False)
# deallocate VRAM
# deallocate VRAM and RAM
del asr_model, df_train, df_eval, df, metadata
gc.collect()
return train_metadata_path, eval_metadata_path, audio_total_size

View File

@ -1,4 +1,5 @@
import os
import gc
from trainer import Trainer, TrainerArgs
@ -164,7 +165,8 @@ def train_gpt(language, num_epochs, batch_size, grad_acumm, train_csv, eval_csv,
trainer_out_path = trainer.output_path
# deallocate VRAM
# deallocate VRAM and RAM
del model, trainer, train_samples, eval_samples
gc.collect()
return XTTS_CONFIG_FILE, XTTS_CHECKPOINT, TOKENIZER_FILE, trainer_out_path, speaker_ref