我正在使用Ray(https://github.com/ray-project/ray)和cython0.29来并行化一些现有的代码,我决定用Cython函数中的一个定义一个cdef类作为它的方法,以简化并行运行多个参与者的代码。我遇到的问题是,当我在cython之后创建类的实例时_简单.py(example6),我得到了一个“太多的参数到了初始化错误”。你知道吗
我有几个问题,但第一个是如何在类实例被雷。遥控器.
我一直在尝试这个方法,其中Test是导入的类:
import ray
from cython_test.cython_test import Test
ray.init()
Test1 = ray.remote(Test)
#Instatiate an actor
args = (img, 10, 10)
a1 = Test1.remote(*args)
但我回来了:
Traceback (most recent call last):
File "test_ray_cython.py", line 25, in <module>
a1 = Test1.remote(*args)
File "/local/data/home/gmosby/.local/lib/python3.7/site-packages/ray/actor.py", line 282, in remote
return self._remote(args=args, kwargs=kwargs)
File "/local/data/home/gmosby/.local/lib/python3.7/site-packages/ray/actor.py", line 384, in _remote
kwargs)
File "/local/data/home/gmosby/.local/lib/python3.7/site-packages/ray/signature.py", line 221, in extend_args
.format(function_name))
Exception: Too many arguments were passed to the function '__init__'
附加信息:这里的Cython类被初始化为def __init__(self, img, nx, ny)
如果我想将Cython类与Ray一起使用,它是否不能有任何初始化参数?你知道吗
解决方法:在Cython类的init方法中用位置参数装饰Cython类似乎失败了,但我决定将一些类成员的设置移到一个单独的函数中。请参见此问题的说明和解决方法(https://github.com/astrophysaxist/cython_test)
解决方法:在Cython类的init方法中用位置参数装饰Cython类似乎失败了,但我决定将一些类成员的设置移到一个单独的函数中。请参见此问题的说明和解决方法(https://github.com/astrophysaxist/cython_test)
相关问题 更多 >
编程相关推荐