You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I notice that even if I set n_jobs=1 in sc.pp.regress_out, all cpus are utilized. This also happens if I set n_jobs to other numbers. Basically there isn't a noticeable difference in cpu usage no matter what number of n_jobs I set. I'm using CentOS6.8 on a machine with 28 physical cores and hyper threading on (appears as 56 cores in the os).
Is this an intended behavior, or just my installation? I understand that some numpy functions are naturally multi-threaded because of the setup of BLAS libraries.
AFAICT, I think the parallelization you're seeing will be due to the underlying calls in statsmodels. If you turn down the number of threads blas can use, do you see the same utilization?
AFAICT, I think the parallelization you're seeing will be due to the underlying calls in statsmodels. If you turn down the number of threads blas can use, do you see the same utilization?
FYI more n_jobs seems to be slower for regress_out if I don't disable the BLAS multi threading:
regressing out ['percent_mito']
sparse input is densified and may lead to high memory use
finished (0:07:41)
I'm using scanpy 1.5.2.dev104+g8611dba1
Indeed after disabling BLAS multi threading sc.pp.regress_out will only use one core if setting n_jobs = 1. But it has to be disable by exporting these environmental variables before starting python ..., but I guess it is not a good thing because other scanpy functions may be affected?
More interesting is that regress_out becomes lightning fast when n_jobs = 24 and with BLAS multi threading disabled:
Thats not too surprising to me. This must be significantly over scheduling your machine.
This got me doing a little more digging into this, and it look's like there's actually a solution now! We can use threadpoolctl to dynamically manage the number of threads BLAS uses via the threadpool_limits context manager.
I'm definitely interested in using this inside scanpy to manage the number of threads used here. Not quite sure yet what the right behaviour/ api is. Some options:
Should all calls use 1 blas thread by default, so parallelization will only happen through the number of jobs?
Do we only limit the number of threads if n_jobs is specified?
Do we try and be fancy, with something like n_threads = n_cpus // n_jobs?
Is there a general fix for this besides zhangguy's great suggestion? (It works but as was stated, but I'm not sure how this alters other functions in the scanpy). I continue to get the putative over scheduling and sometimes a crash (on big datasets) when using all cores versus the super fast completion when using 1/2 cores) on a 32 core/64 thread threadripper. (RAM doesn't seem to be a problem as I'm barely touching 10% of the 256GB.)
Activity
JBreunig commentedon Aug 29, 2020
I have the same issue on Ubuntu 20.04.
ivirshup commentedon Aug 31, 2020
AFAICT, I think the parallelization you're seeing will be due to the underlying calls in statsmodels. If you turn down the number of threads blas can use, do you see the same utilization?
zhangguy commentedon Aug 31, 2020
FYI more n_jobs seems to be slower for regress_out if I don't disable the BLAS multi threading:
I'm using scanpy 1.5.2.dev104+g8611dba1
Indeed after disabling BLAS multi threading sc.pp.regress_out will only use one core if setting n_jobs = 1. But it has to be disable by exporting these environmental variables before starting python ..., but I guess it is not a good thing because other scanpy functions may be affected?
More interesting is that regress_out becomes lightning fast when n_jobs = 24 and with BLAS multi threading disabled:
ivirshup commentedon Sep 14, 2020
Thats not too surprising to me. This must be significantly over scheduling your machine.
This got me doing a little more digging into this, and it look's like there's actually a solution now! We can use
threadpoolctlto dynamically manage the number of threads BLAS uses via thethreadpool_limitscontext manager.I'm definitely interested in using this inside scanpy to manage the number of threads used here. Not quite sure yet what the right behaviour/ api is. Some options:
n_jobsis specified?n_threads = n_cpus // n_jobs?Minor update
If we use
joblib(with thelokybackend) instead ofmultiprocessing, the fancy solution will be used by default.I think this is what the code would look like inside of
regress_out:JBreunig commentedon Nov 2, 2020
Is there a general fix for this besides zhangguy's great suggestion? (It works but as was stated, but I'm not sure how this alters other functions in the scanpy). I continue to get the putative over scheduling and sometimes a crash (on big datasets) when using all cores versus the super fast completion when using 1/2 cores) on a 32 core/64 thread threadripper. (RAM doesn't seem to be a problem as I'm barely touching 10% of the 256GB.)