-
Hi all - I posted this on StackOverflow, and I'm repeating it here. I'm using the AllenNLP (version 2.6) semantic role labeling model to process a large pile of sentences. My Python version is 3.7.9. I'm on MacOS 11.6.1. My goal is to use In the parent process, I have explicitly placed the model in shared memory as follows:
I know the model is only being loaded once, in the parent process. And I place the model in shared memory whether or not I'm going to make use of the pool. I'm using I'm calling the predictor in the pool using Here's what happens, for a batch of 395 sentences:
The more processes, the worse the total AllenNLP processing time - even though the model is explicitly in shared memory, and the only thing that crosses the process boundary during the invocation is the input text and the output JSON. I've done some profiling, and the first thing that leaps out at me is that the function Any pointers or suggestions would be appreciated. |
Beta Was this translation helpful? Give feedback.
Replies: 6 comments 13 replies
-
That's very likely and would be my first guess as well. I'm not totally sure what |
Beta Was this translation helpful? Give feedback.
-
Well, my next thought was to try to defeat the memory sharing, and I redefined |
Beta Was this translation helpful? Give feedback.
-
I have tried this, in fact, I've tried several iterations, since each time I suspected that I had somehow failed to isolate the child process elements. I've found no way to reduce the multiprocessing below the numbers in the original question. It scales with the number of processes, and I'm still nowhere near hitting the limit of memory on my machine. Nothing should be swapped, and nothing should be shared, but yet I can't get single-process speed in the child processes no matter what I try. |
Beta Was this translation helpful? Give feedback.
-
And, to answer the obvious question, when I run two non-parallel processes in two different shells, the processing speed is single-process in both. I'm wondering whether, somehow, the torch mechanism for shared memory is looking at the model I'm loading again and putting it in shared memory because multiple children are using the same model, regardless of whether it's the same model instance. |
Beta Was this translation helpful? Give feedback.
-
I'll see if I can pare something down - the code is complicated and not publicly available.
I'm off this week - back next week.
Pete wrote:
… Do you have a snippet of code you could share? If I had something to run I'd be interested in debugging this.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub <#5471 (reply in thread)>, or unsubscribe <https://github.com/notifications/unsubscribe-auth/ABKR73CTXXZFNKHFKZRYGZDUNJYTNANCNFSM5IIGOCGQ>.
Triage notifications on the go with GitHub Mobile for iOS <https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675> or Android <https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Beta Was this translation helpful? Give feedback.
-
It would be weird to mark the previous thread as the answer, since it's buried deep in the replies, but the answer appears to be that once I time things carefully enough, the mystery goes away, probably because I wasn't taxing my machine enough in the right ways in the baseline case. Thanks to @epwalsh for his patience. |
Beta Was this translation helpful? Give feedback.
It would be weird to mark the previous thread as the answer, since it's buried deep in the replies, but the answer appears to be that once I time things carefully enough, the mystery goes away, probably because I wasn't taxing my machine enough in the right ways in the baseline case. Thanks to @epwalsh for his patience.