我已经安装了dill/pathos及其依赖项(有点困难),我正试图在几个进程上执行一个函数。类/属性Model(self.xml,self.exp_data,i).SSR
是定制的,它依赖于其他自定义函数的加载,因此我提前为无法提供“可运行”代码而道歉。简而言之,它需要一些实验数据,将ODE系统与python的pysces模块集成,并计算平方和(SSR
)。将此代码并行化的目的是用多个参数集来加速此计算。在
代码:
import multiprocess
def evaluate_chisq(pop):
p = multiprocess.Pool(8)
res= p.map(lambda i:Model(self.xml,self.exp_data,i).SSR , pop)#calcualteSSR with this parameter set
return res
我得到的错误消息是:
^{pr2}$然后我尝试使用map_async
:
def evaluate_chisq(pop):
p = multiprocess.Pool(8)
res= p.map_async(lambda i:Model(self.xml,self.exp_data,i).SSR , pop)#calcualteSSR with this parameter set
return res
它返回一个<multiprocess.pool.MapResult object at 0x0000000014AF8C18>
对象,当我试图使用MapResult
的“get”方法时,它会给我同样的错误
File "C:\Anaconda1\lib\site-packages\multiprocess\pool.py", line 567, in get
raise self._value
AssertionError
有人知道我做错了什么吗?在
在Windows上,您需要使用来自
__main__
的freeze_support
。在见https://docs.python.org/2/library/multiprocessing.html#multiprocessing.freeze_support。在
相关问题 更多 >
编程相关推荐