I want to assign my computing jobs to more than one cpu, so I choose multiprocessing. However, the result is not what I want.
import numpy as np from multiprocessing import Process def func(begin,end): print('*'*5) print('begin=%d' %(begin)) for i in range(begin,end): for j in range(10): myarray[i][j]=1 myarray=np.zeros((12,10)) print(myarray) for i in range(4): begin=i*3 end=(i+1)*3 p=Process(target=func,args=(begin,end,)) p.start() print('*'*5) print(myarray) I think that myarray should be all ones. But it doesn't change at all. Why? The func function does not change elements of myarray? I tried the example from this linkenter link description here
from multiprocessing import Process def f(name): print('hello',name) p=Process(target=f,args=('bob',)) p.start() It shows nothing on the screen. Why? How should I finish my computation with python? Can anyone give a way of fully take advantage of multi-cpus?
('hello', 'bob')