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

Deleting StableEmbedding still occupies GPU RAM #1462

Open
KMFODA opened this issue Dec 22, 2024 · 0 comments
Open

Deleting StableEmbedding still occupies GPU RAM #1462

KMFODA opened this issue Dec 22, 2024 · 0 comments

Comments

@KMFODA
Copy link

KMFODA commented Dec 22, 2024

System Info

Python 3.10.6
Ubuntu 22.04.2 LTS
transformers 4.39.3

Reproduction

import torch
import gc
import bitsandbytes

wte = bitsandbytes.nn.modules.StableEmbedding(50257, 1904)
wpe = bitsandbytes.nn.modules.StableEmbedding(50257, 1904)
wte.to("cuda")
wpe.to("cuda")

del wte
del wpe
gc.collect()
torch.cuda.empty_cache()

print(torch.cuda.memory_allocated() / 1024**3)
# 0.7148723602294922
print(torch.cuda.memory_reserved() / 1024**3)
# 0.716796875

Expected behavior

I've attached the following snippet of code which is a simplication for the actual problem I'm facing. I've built a version of GPT that has Stable Embeddings and my use case requires me to constantly be reloading new versions of that model. I find that this leads to a gradual increase in GPU RAM usage over time.

To investigate this I've tried initialising the StableEmbeddings components on their own as per the above code snippet and then deleting them. The issue is that when I delete the variable and then empty out the cuda cache the GPU memory is still occupied by it.

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

1 participant