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

CUDA memory cache increasing #37

Open
nepoyasnit opened this issue Jul 16, 2024 · 2 comments
Open

CUDA memory cache increasing #37

nepoyasnit opened this issue Jul 16, 2024 · 2 comments

Comments

@nepoyasnit
Copy link

I've run gradio app from repo and saw that CUDA memory grows rapidly from ~3 Gbs to ~12Gbs.
If i put small audio, it is also increasing, but not so much.

CUDA memory when i put small (1 second) audio file:
image

CUDA memory after putting long audio file (2.5 minutes):
image

Also, I've checked torch.cuda.memory_allocated() and it was constant, but torch.cuda.memory_cached() was increasing.
Maybe someone can explain me, why CUDA cache is growing?

@Cooperos
Copy link

Also, I've checked torch.cuda.memory_allocated() and it was constant, but torch.cuda.memory_cached() was increasing. Maybe someone can explain me, why CUDA cache is growing?

When you free a tensor, the memory is not returned to the GPU immediately. Instead, it is cached by PyTorch to be reused for future allocations. This is why torch.cuda.memory_cached() can increase over time, even if torch.cuda.memory_allocated() remains constant.

Pytorch docs

@nepoyasnit
Copy link
Author

Also, I've checked torch.cuda.memory_allocated() and it was constant, but torch.cuda.memory_cached() was increasing. Maybe someone can explain me, why CUDA cache is growing?

When you free a tensor, the memory is not returned to the GPU immediately. Instead, it is cached by PyTorch to be reused for future allocations. This is why torch.cuda.memory_cached() can increase over time, even if torch.cuda.memory_allocated() remains constant.

Pytorch docs

Yes, but it is strange that with the growth of requests, the size of the enhancer increases so much. Also, i think it's strange to have 13Gb CUDA memory, when only ~3 of that is allocated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants