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

cpu count vs available cpu :: potential overcommit #1199

Closed
EricDeveaud opened this issue Mar 10, 2023 · 2 comments
Closed

cpu count vs available cpu :: potential overcommit #1199

EricDeveaud opened this issue Mar 10, 2023 · 2 comments

Comments

@EricDeveaud
Copy link

deepTools uses multiprocessing.cpu_count() to get the number of cpus via deeptools/parserCommon.py.
multiprocessing.cpu_count() return the number of cpu in the machine, But this is not the same as the number of available cpu to the process. For example, you can run in a taskset context or a batch scheduler like slurm.

see:

$ nproc
96
$ taskset -c 1 nproc
1
$ taskset -c 1 python3 -c "import multiprocessing; print(multiprocessing.cpu_count())"
96

I would suggest to use len(os.sched_getaffinity(0)) instead of multiprocessing.cpu_count()

$ python3 -c "import os; print(len(os.sched_getaffinity(0)))"
96
$ taskset -c 1 python3 -c "import os; print(len(os.sched_getaffinity(0)))"
1

NB Mac OSX python does not have os.sched_getaffinity so a portable way to code it would be

try:
num_cpus = len(os.sched_getaffinity(0))
except AttributeError:
num_cpus = multiprocessing.cpu_count()

regards

Eric

@EricDeveaud
Copy link
Author

hello still have the same problem with version 3.5.4

regards

Eric

@WardDeb WardDeb mentioned this issue Jan 17, 2024
4 tasks
@WardDeb
Copy link
Member

WardDeb commented Jan 17, 2024

Thanks for the report, and sorry for the delay..
Your suggestion has been merged into develop, there's a new release coming soon.

Kind regards,

WardDeb

@WardDeb WardDeb closed this as completed Jan 17, 2024
@WardDeb WardDeb mentioned this issue Mar 8, 2024
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

No branches or pull requests

2 participants