如何解决使用MPIPoolExecutor时出错:引发self._exception TypeError:无法腌制_thread.lock对象
我是MPIPoolExecutor的新手,需要在我的项目中使用三个参数x,y和z多次计算一个耗时的函数,其中z遍历大型NumPy数组Z。此函数返回一个列表:>
my_output = [self.my_function(x,y,z) for z in self.Z]
因为这部分程序太慢,所以我试图使用MPIPoolExecutor来加快速度。 执行器在 init 函数中初始化:
self.executor = MPIPoolExecutor(max_workers=3)
然后在我编写的方法中:
arg_2 = list(repeat(x,len(self.Z)))
arg_3 = list(repeat(y,len(self.Z)))
prob_pool = self.executor.map(self.my_function,self.Z,arg_2,arg_3)
prob_pool_list = list(prob_pool)
不幸的是,我收到了我无法理解的错误:
File ".../lib/python3.6/site-packages/mpi4py/futures/pool.py",line 207,in result_iterator
yield futures.pop().result()
File "/usr/lib/python3.6/concurrent/futures/_base.py",line 432,in result
return self.__get_result()
File "/usr/lib/python3.6/concurrent/futures/_base.py",line 384,in __get_result
raise self._exception
TypeError: can't pickle _thread.lock objects
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。