-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Memory Leak when running encoding in ThreadPool #1854
Comments
Seems potentially related to: |
In #1795 a sample similar to your non-threaded variant also seems to fail. Not sure if this is related but there have been multiple issues regarding memory leaks lately. |
Update: I just had a few minutes and tried the above script when everything within the main loop of for start_index in trange(0, len(sentences), batch_size, desc="Batches", disable=not show_progress_bar):
sentences_batch = sentences_sorted[start_index:start_index + batch_size]
features = self.tokenize(sentences_batch)
del features
return [] The leak is showing even then. Once I delete tokenize (and return constant output) the leak is gone. So there is at least a problem in (Off Topic: Why is this extra Transformer class needed?) This lead me to a very old issue here: huggingface/transformers#197. This is my progress so far, will stop now, but maybe these notes will help. Edit: similar issue here Edit2:
Seems there are multiple problems but the tokenizer is only an issue for the model |
Found the same issue when encoding an image with clip, when in a thread the memory continues to increase, but when running in a loop, the memory remains constant. |
I have seen a curious behavior when running the
encoding
of asentence-transformer
model insida athreadPool
.Look at this code which runs with no problem and constant memory consumption:
On the other hand, this code blows the system memory and rapidly leads to an OOM:
The only difference is that the
encoding
happens inside aThread
.The text was updated successfully, but these errors were encountered: