forked from pjreddie/darknet
-
Notifications
You must be signed in to change notification settings - Fork 8k
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
Multiprocessing in darknet_video.py (NOT final!) #8567
Open
CristiFati
wants to merge
15
commits into
AlexeyAB:master
Choose a base branch
from
CristiFati:cfati_dev02
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Also, the test env is quite poor. Many tests fail because of setup issues totally unrelated to the changes. |
if you rebase on top of master, errors should go away. Sorry for the noise |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Disclaimer
I'm not aiming to merge this PR anywhere (that's the reason why I left there debug and other stuff), it's just a point that I've reached (and got stuck at). If anyone is interested, they can use this
This is on top of Fix thread synchronization bug + many more #8562. It contains it (otherwise the PR wouldn't make sense), ONLY LAST COMMIT IS RELEVANT
As I explained in the prerequisite PR, on my laptop (pretty old), I get ~3 FPS:
NVidia Quadro M100M - GPU
Win 10 pc064
Python 3.9
In theory, switching to multi process could increase speed by a factor of up to 3 (as they are 3 threads), but a more realistic estimation would be ~1.5 - 2 (I thought that with a reasonable amount of work, I'd get some good results). However they are very disappointing, as it performs even worse (~2 FPS). On one hand, it makes sense as it needs to pickle / unpickle lots of stuff for each frame.
There are other drawbacks as well:
I know the synchronization mechanism (if it can be called that) is rudimentary, but it crashes at the end (didn't do a deep debug session to find out why), and it requires Ctrl+ Break
Besides that, the model is loaded twice, (one just to get some data out of it - as it can't be pickled)
While we are on pickleing subject, one thing that I don't understand is why only the IMAGE class needed adjustments, as other structures (DETECTION) are being shared between processes as well (via Queues)
The 3 function signatures became horribly long
Some (visual) details: [SO]: Changing YoloV4 darknet_video.py into multiprocessing instead of multi_threading (@CristiFati's answer).
I think with a lot of refactoring, things could be improved (maybe even change the number of threads (ExecUnits)), but I didn't do any profiling to see where it "sits" most.