【问题标题】:Object Spilling in Ray光线中的物体溢出
【发布时间】:2022-08-03 06:15:37
【问题描述】:

我有一个使用 ray 的脚本,如下所示:

import ray
from PIL import Image

ray.init(
    object_store_memory=1000 * 1024 * 1024 * 100,
    ignore_reinit_error=True,
    num_cpus=128,
    num_gpus=1,
)

img_paths = np.array([200k image paths])

@ray.remote
def read_img(path):

    img = np.asarray(Image.open(path))

    return img


images = ray.get([read_img.remote(path) for img_path in img_paths[:10000]])

当我通过img_paths[:5000] 处理约 5000 张图像时,该程序在大约 5 秒内执行。当我将其提高到 ~10000 时,程序需要 4 分钟才能执行并给我如下消息:

(raylet) Spilled 132187 MiB, 12533 objects, write throughput 1052 MiB/s.

这是我第一次使用 ray,所以我不确定如何防止这种情况发生。

  • 嗨,加文!为了及时回复,我建议您在Ray Discuss siteSlack 中链接到此问题。雷人密切监视这些并可以回答!

标签: python python-3.x multiprocessing python-multiprocessing ray


【解决方案1】:

最终通过processing my images in batches 解决了这个问题。系统未分配请求的 100 GB 内存,因此对象仍在溢出。看起来像这样:

refs = [read_img.remote(path) for path in paths]
images = np.empty((1920, 1920))

for i in range(len(refs) // 5000 + 1):

    images = np.vstack(
        (images, np.array(ray.get(refs[i * 5000 : (i + 1) * 5000])))
    )

【讨论】:

    猜你喜欢
    • 2019-06-30
    • 2018-11-13
    • 1970-01-01
    • 1970-01-01
    • 2016-03-17
    • 1970-01-01
    • 2022-01-09
    • 2017-05-26
    • 2022-06-15
    相关资源
    最近更新 更多