libphy
libphy

Reputation: 121

python multiprocessing with multiple cpus?

I have two Xeon processors (each has 8 cores, so total 32 threads) on my MOBO, and I ran a simple code using multiprocessing.Pool(processors=30). When I monitor using htop, I find that only 12 threads are utilized. Does anyone know why that might be happening?

Upvotes: 0

Views: 510

Answers (1)

Genuine
Genuine

Reputation: 264

Pool() can provide a specified number of processes for user invocations when a new request is submitted to the Pool, and if the Pool is not full, a new process is created to execute the request; But if the number of processes in the pool has reached the specified maximum, the request will wait until there is a process in the pool to create a new process.
For a model that supports multi-threading, the number of threads recommended is at least 1:1. 5. This allows some threads to do IO.
And if your process doesn't use a full core, it won't take up another core.

Upvotes: 1

Related Questions