Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Memory Leak while using VITS model #298

Open
abhijitpal1247 opened this issue Feb 14, 2025 · 1 comment
Open

[Bug] Memory Leak while using VITS model #298

abhijitpal1247 opened this issue Feb 14, 2025 · 1 comment
Labels
bug Something isn't working

Comments

@abhijitpal1247
Copy link

Describe the bug

While querying the vits model for a number of texts, there seems to be a memory leakage. The memory consumption almost linearly increases as the loop progresses.

To Reproduce

 import os
 import torch
 from TTS.api import TTS
 
 
 # Get device
 device = "cpu"
 
 tts = TTS("tts_models/en/vctk/vits").to(device)
 
 
 texts_to_test = [
 "some 112 pieces of text, each consisting of multiple lines ...."
 ]
 
 
 speaker = tts.speakers[0]
 num_requests = 0
 for idx, txt in enumerate(texts_to_test):
     wav = tts.tts(text=txt, speaker=speaker, speed=0.8)

To reproduce the issue just replace texts_to_test with a list of good number of texts (>100) and each text should consist of 2-3 lines.
I performed this experiment on a c2-standard-4 machine (gcp).

Expected behavior

The consumption of RAM should be stable and should not increase while running the given code.

Logs

Environment

{
     "CUDA": {
         "GPU": [],
         "available": false,
         "version": "12.4"
     },
     "Packages": {
         "PyTorch_debug": false,
         "PyTorch_version": "2.6.0+cu124",
         "TTS": "0.25.3",
         "numpy": "1.26.4"
     },
     "System": {
         "OS": "Linux",
         "architecture": [
             "64bit",
             "ELF"
         ],
         "processor": "x86_64",
         "python": "3.10.16",
         "version": "#23~22.04.1-Ubuntu SMP Thu Jan 16 02:17:57 UTC 2025"
     }
 }

Additional context

No response

@abhijitpal1247 abhijitpal1247 added the bug Something isn't working label Feb 14, 2025
@abhijitpal1247 abhijitpal1247 changed the title [Bug] [Bug] Memory Leak while using VITS model Feb 14, 2025
@juangon
Copy link

juangon commented Feb 27, 2025

I think using:

import gc gc.collect() torch.cuda.empty_cache()

fixes this for me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants