0
我有兩個函數,core_ensembling和sampling.core集合返回值。我需要並行化採樣函數內的core_ensebling函數,即我需要並行計算set1,set2,set3 ... set6。所有這些計算都是獨立的。那麼,是否可以並行這個節目呢?我。怎麼可以這樣做?我使用Windows 10,其中有2個核心和Python的英特爾i3處理器的2.7如何並行化在Python中返回值的函數?
def core_ensembling(args):
#some code#
return ensemble_set
def sampling(p,q):
total_frames=q
ensemble_row=6
ensemble_col=8
frame_ensemble=[]
ensemble_set=[]
args1=[8,0,80,total_frames,p]
args2=[16,80,160,total_frames,p]
args3=[24,160,240,total_frames,p]
args4=[32,240,320,total_frames,p]
args5=[40,320,400,total_frames,p]
args6=[48,400,480,total_frames,p]
# parallising part
set1=core_ensembling(args1)
set2=core_ensembling(args2)
set3=core_ensembling(args3)
set4=core_ensembling(args4)
set5=core_ensembling(args5)
set6=core_ensembling(args6)
ensemble = list(itertools.chain(set1,set2,set3,set4,set5,set6))
return ensemble
謝謝你,但有誤差** RuntimeError : 嘗試在當前進程 完成其引導階段之前嘗試啓動新進程。** – user6745741
@ user6745741:請參閱http:// stackover flow.com/a/18205006/4323 –