High Kernel Cpu When Running Multiple Python Programs
I developed a python program that does heavy numerical calculations. I run it on a linux machine with 32 Xeon CPUs, 64GB RAM, and Ubuntu 14.04 64-bit. I launch multiple python inst
Solution 1:
If the problem exists in kernel, you should narrow down a problem using a profiler such as OProfile or perf.
I.e. run perf record -a -g
and than read profiling data saved into perf data
using perf report
. See also: linux perf: how to interpret and find hotspots.
In your case high CPU usage is caused by competition for /dev/urandom
-- it allows only one thread to read from it, but multiple Python processes are doing so.
Python module random
is using it only for initialization. I.e:
$ strace python -c 'import random;
while True:
random.random()'open("/dev/urandom", O_RDONLY) = 4read(4, "\16\36\366\36}"..., 2500) = 2500close(4) <--- /dev/urandom is closed
You may also explicitly ask for /dev/urandom
by using os.urandom
or SystemRandom
class. So check your code which is dealing with random numbers.
Post a Comment for "High Kernel Cpu When Running Multiple Python Programs"