How does nlp.pipe work to prevent OOM? #9944
-
I am using a transformer-based model with require_gpu. I can confirm that my code works even when batch size is set to 1024 in pipe() on a 16GB GPU. So I wonder, does pipe internally do something special (smaller minibatches based on some heuristic or catching OOM and systematically lowering batch size?) to ensure that out-of-memory issues don't occur? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hi Bram! Happy to hear things are working well for you. You can find the code for Is there a particular reason why you're asking? (I might not have understood the question) |
Beta Was this translation helpful? Give feedback.
Hi Bram! Happy to hear things are working well for you.
You can find the code for
nlp.pipe
here: https://github.com/explosion/spaCy/blob/master/spacy/language.py#L1487. You can see thatbatch_size
is used as such. Ifn_process>1
, the functionself._multiprocessing_pipe
is called which in turn callsutil.minibatch
with the samebatch_size
.Is there a particular reason why you're asking? (I might not have understood the question)