首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >具有多个返回并调用ray.get()的ray.get示例

具有多个返回并调用ray.get()的ray.get示例
EN

Stack Overflow用户
提问于 2021-02-23 17:15:45
回答 1查看 1.5K关注 0票数 3

下面的代码执行所需的行为。是否有可能传递前两个函数的第二个参数而不必过早调用ray.get

代码语言:javascript
复制
@ray.remote
def color():
    image=cv2.imread("frame30.png", flags=0)
    argument= "Hello"
    return image,argument

@ray.remote
def black():
    image=cv2.imread("frame30.png", flags=0)
    argument= "world"
    return image,argument

@ray.remote
def concate_two_args(a,b):
    return a + " " + b

col= color.remote()
blk= black.remote()

#Do I have to "ray.get" in order to pass the results to concate_two_args?
temp1= ray.get(col)[1]
temp2= ray.get(blk)[1]

results= concate_two_args.remote(temp1,temp2)

ray.get(results)

直接这样做

代码语言:javascript
复制
col, string= color.remote()

ray.get(string)

返回

代码语言:javascript
复制
TypeError: cannot unpack non-iterable ray._raylet.ObjectRef object
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2021-02-24 05:15:32

您能尝试将num_returns添加到@ray.remote吗?例如,

代码语言:javascript
复制
@ray.remote(num_returns=2)
def color():
    image=cv2.imread("frame30.png", flags=0)
    argument= "Hello"
    return image,argument

@ray.remote(num_returns=2)
def black():
    image=cv2.imread("frame30.png", flags=0)
    argument= "world"
    return image,argument
票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66337907

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档