-
Notifications
You must be signed in to change notification settings - Fork 82
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
Why future use more CPU than worker number? #343
Comments
It looks like workers are using multi-threading, for example, |
@renkun-ken Thanks. Do you mean I still cannot understand the difference between
Do you have any idea to limit cores used for computation in |
futures only starts processes, i.e. a worker. Some packages use OpenMP or some other multi-threading techniques to improve performance. If multi-threading is enabled, each worker may start multiple threads. The overall CPU usage can be very high if many threads are working. Even if you only start 2 workers, if each worker also starts 20 threads, you will observe all CPUs are occupied. |
@renkun-ken Yes, it is indeed what I observed when I set different number of workers. But I cannot find a solution to limit it 😢. I think it is a disaster if all CPUs are occupied too much time, it will affect other programs and users in linux server. |
There are plenty of methods to limit the number of threads. Some packages provide their own get/set threads functions, e.g. Some functions or packages use BLAS and do not provide a function to limit the number of threads. In this case, you may try RhpcBLASctl, which provided functions to limit the number of threads of both OpenMP and BLAS. For Linux server with multiple users, I suggest that every user always limit the max number of threads to use. |
@renkun-ken Thanks, I will take a try. |
I would like to add that
works for me, while
Does not work and I see CPU +100% when looking at |
I specified
workers = 16
but all 24 cores are used when setfuture::plan("multiprocess", workers = 16)
The text was updated successfully, but these errors were encountered: