Python同期期货递归函数中的UMAP fit_转换发生brokenprocessspool错误

2024-09-30 20:25:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试并行化一个递归程序,该程序在每个递归步骤中都使用UMAP fit_转换,使用同期期货. 该程序基本上对pandas数据帧应用UMAP fit_转换,然后将该数据帧拆分并再次递归地应用fit_转换。同样,需要注意的是,它在每一步都传递一个包含新pandas数据帧的对象。 我遇到一个“进程池损坏”错误,它似乎来自队列.full例外情况。在UMAP fit_transform步骤中,程序在每个进程中都会遇到错误。 我不是在UMAP中并行,我只是在多个单独的进程中调用一个递归函数,每个进程都使用UMAP。有人在并行递归函数时遇到过类似的情况吗?当递归地创建要并行化的对象时,是否存在内存使用过多的可能性?在

我尝试过增加RAM限制,以及Python中不同的多处理库(同期期货,多处理池等)。我还发现,当以非递归方式使用时,我可以无错误地应用UMAP fit_transform。在

这是我如何设置并行步骤:

class UmapObj:
    // Hold a pandas dataframe
    // Has a method (doUmap) that applies UMAP on the dataframe,
    // then splits it into sub matrices and applies UMAP again
    // recursively, at each stage joins matrices together


def doUmapWrap(UmapObj):
    UmapObj.doUmap()

ex = futures.ProcessPoolExecutor(max_workers=4)

arr = [UmapObj1, UmapObj2, UmapObj3] // Note: arr contains UmapObjects
outarr = []

for f in arr:
    i = ex.submit(doUmapWrap, f)
    outarr.append(i)

for i in outarr:
    print(i.result().df)

这是我得到的错误回溯:

“/Users/anantmaheshwari/anaconda/lib/python3.6/concurrent/futures”/_基准.py“,第405行,在结果中 线程1中出现异常: 回溯(最近一次呼叫): 文件“/Users/anantmaheshwari/anaconda/lib/python3.6/线程.py“,第916行,内部引导 自行运行() 文件“/Users/anantmaheshwari/anaconda/lib/python3.6/线程.py“,第864行,运行中 自我目标(*self.\u args,**self.\u kwargs) 文件“/Users/anantmaheshwari/anaconda/lib/python3.6/concurrent/futures/进程.py,第295行,队列管理工作人员 关闭工作机() 文件“/Users/anantmaheshwari/anaconda/lib/python3.6/concurrent/futures/进程.py“253号线,停堆工作人员 呼叫_queue.put_nowait队列(无) 文件“/Users/anantmaheshwari/anaconda/lib/python3.6/multiprocessing/队列.py“,第129行,输入 返回自投(obj,错误) 文件“/Users/anantmaheshwari/anaconda/lib/python3.6/multiprocessing/队列.py“,第83行,输入 加满 队列。已满在

返回self.\uu get_result() 文件“/Users/anantmaheshwari/anaconda/lib/python3.6/concurrent/futures/_基准.py“,第357行,在“获取结果”中 自我提升。例外 并发期货过程.BrokenProcessPool:当未来正在运行或挂起时,进程池中的某个进程突然终止。在


Tags: 文件py程序队列进程lib错误步骤