下面的代码执行所需的行为。是否可以从前两个函数传递第二个参数而不必提前调用ray.get?
@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)
Run Code Online (Sandbox Code Playgroud)
直接这样做
col, string= color.remote()
ray.get(string)
Run Code Online (Sandbox Code Playgroud)
回报
TypeError: cannot unpack non-iterable ray._raylet.ObjectRef object
Run Code Online (Sandbox Code Playgroud)
小智 5
您可以尝试添加num_returns到吗@ray.remote?例如,
@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
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2766 次 |
| 最近记录: |