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

The GPU memory will keep increase #35

Open
sev777 opened this issue Jul 16, 2024 · 1 comment
Open

The GPU memory will keep increase #35

sev777 opened this issue Jul 16, 2024 · 1 comment

Comments

@sev777
Copy link

sev777 commented Jul 16, 2024

I noticed that when continuously analyzing multiple data streams with neurons, the GPU memory usage keeps increasing, eventually leading to an overflow. Is there any way to solve this problem?

@Lut-hub
Copy link

Lut-hub commented Sep 13, 2024

Hi, I came through the same question. And this may be caused by the KnowledgeNeurons class not releasing its memory in time. You can try del and torch.cuda.empty_cache(), like:

for dat in tqdm(new_data[:batch_size]):
    kn_ml = KnowledgeNeurons(ml_model, tokenizer, model_type=model_type(MODEL_NAME))
    TEXT = dat["question"]
    ANS = dat["answer"]
    test_neurons = kn_ml.get_scores(prompt=TEXT, ground_truth=ANS, pbar=False).cpu().detach().clone()
    del kn_ml
    torch.cuda.empty_cache()

Hope this might help! 😃

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