My python script, which is essentially like the example code below, fails to use two processors for two independent processes create via the multiprocessing
module.
Two processes are created, executed, and joint, but all happens on a single core.
I have trouble in understanding what is the problem, since on a different machine everything is as expected. multiprocessing.cpu_count()
returns 4
on either machine.
So my question is a bit vague: What might be the reason, that the processes do not use all available processors.
Example code:
import numpy as np
import multiprocessing
n = 10
mat = np.random.randn(n, n)
vec = np.ones((n, 1))
def compprod():
print np.dot(mat, vec)
return
def compsum(times):
print times*vec
return
p1 = multiprocessing.Process(target=compprod)
p2 = multiprocessing.Process(target=compsum, args=(n, ))
p1.start()
p2.start()
p1.join()
p2.join()
print 'done'