我正在使用并行 python 在多台计算机上进行一些数字运算。一切都很好,直到我认为加入一些课程会很好。
以下是提交作业的代码:
for i in xrange(n_cpus):
jobs.append(job_server.submit(self.fcalc_rs_rp, (ch_lambdas[i], thetas, ch_n_arr[i]), (), ("import numpy as np", "from SimulationOO import *")))
它在单台计算机上运行良好(也使用所有内核,非常好),但如果我尝试使用另一台服务器,计算永远不会停止。
问题是服务器没有cpu负载,因为from SimulationOO import *
服务器上不存在文件,所以无法加载。
一种解决方法是将方法.fcalc_rs_rp()
从类中取出并使其成为函数,但实际上我希望将函数放在类中,也许您有一个好主意?
如果我尝试不使用该from SimulationOO import *
部分,而是将所有需要的函数定义为 depfuncs,它会给出错误AttributeError: 'module' object has no attribute 'Layer'
where Layer
is one of the classes 我正在使用。
你有什么建议,我怎么能让这个工作?
谢谢