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

Speed up metrics computation by parallelizing across subjects #11

Merged
merged 6 commits into from
Jun 11, 2024

Conversation

naga-karthik
Copy link
Member

@naga-karthik naga-karthik commented Jun 9, 2024

This PR is an initial attempt at parallelizing the computation of metrics across subjects using multiprocessing. The usage is similar to that of sct_run_batch -- an additional arg -jobs has been added to process subjects in parallel.

I even tried parallelizing across labels (i.e. nested parallelization with 1st parallelism across subjects and 2nd level of parallelism across labels for each subject). BUT, this resulted in an error AssertionError: daemonic processes are not allowed to have children -- which essentially means that child processes are not allowed to create further child processes.

Hence, in this version, parallelization is only happening at one level. If we want to parallelize the computation across multiple subjects, we should avoid parallelizing within each subject's computation (i.e. no parallelization within the labels).

@valosekj could you please give this PR a try and see if you see some speed ups?

Related: #10

@valosekj
Copy link
Member

I fixed the printing issues in my recent commits:

image

I also fixed the failing CI in 615ed07. I do not know how it is possible that the CI worked for main, though.

@valosekj
Copy link
Member

valosekj commented Jun 10, 2024

I compared main with your branch on site-003 on romane and I found out that the speed is actually very similar (22 minutes vs 18 minutes).

single CPU processing: main: 22m13.9s Screenshot 2024-06-10 at 12 12 10 PM
parallel processing: nk/faster-metrics-computation `-jobs 11`: 18m9.5s Screenshot 2024-06-10 at 2 13 59 PM

@naga-karthik naga-karthik marked this pull request as ready for review June 11, 2024 18:49
@naga-karthik naga-karthik merged commit 76dbb55 into main Jun 11, 2024
3 checks passed
@valosekj valosekj deleted the nk/faster-metrics-computation branch June 12, 2024 01:17
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

Successfully merging this pull request may close these issues.

2 participants