I'm trying to run a ray task in nested loop.
Each loop takes dataA which has 5000 rows of list.
In ray task, it takes dataB and dataC that are 5000 x 256, 5000 x 768 respectively.
Whenever ray task runs, out of memory error occurs and then worker gets killed with below implementation.
How can I avoid this error?
我正在尝试在嵌套循环中运行射线任务。每个循环获取具有5000行列表的dataA。在射线任务中,它获取的数据B和数据C分别为5000 x 256、5000 x 768。每当ray任务运行时,就会发生内存不足错误,然后下面的实现会导致工作人员死亡。如何避免此错误?
import ray
import os
num_cpu = os.cpu_count()
ray.init(num_cpus=num_cpu)
dataB = ray.put(dataB) # 5000 x 256
dataC = ray.put(dataC) # 5000 x 768
@ray.remote
def calculate(dataB, dataC):
calcResult = someCalculationWithDataBAndC()
return calcResult
for i in range(len(dataA)):
for j in range(i + 1, len(dataA), 1):
resultList = [calculate.remote(dataB, dataC, i, j)]
resultList = ray.get(resultList)
ray.shutdown()
更多回答
优秀答案推荐
我是一名优秀的程序员,十分优秀!