返回介绍

parl.remote_class

发布于 2024-06-23 17:58:49 字数 1700 浏览 0 评论 0 收藏 0

class remote_class(*args, **kwargs)[源代码]

A Python decorator that enables a class to run all its functions remotely.

Each instance of the remote class can be seemed as a task submitted to the cluster by the global client, which is created automatically when we call parl.connect(master_address). After global client submits the task, the master node will send an available job address to this remote instance. Then the remote object will send local python files, class definition and initialization arguments to the related job.

In this way, we can run distributed applications easily and efficiently.

@parl.remote_class
class Actor(object):
    def __init__(self, x):
        self.x = x

    def step(self):
        self.x += 1
        return self.x

actor = Actor()
actor.step()

# Set maximum memory usage to 300 MB for each object.
@parl.remote_class(max_memory=300)
class LimitedActor(object):
   ...
参数:
  • max_memory (float) – Maximum memory (MB) can be used by each remote instance, the unit is in MB and default value is none(unlimited).

  • n_gpu (int) – The number of GPUs required to run the remote instance.

返回:

A remote wrapper for the remote class.

抛出:

Exception – An exception is raised if the client is not created by parl.connect(master_address) beforehand.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文