parl.remote_class¶
-
class
remote_class
[source]¶ 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): ...
Parameters: - 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.
Returns: A remote wrapper for the remote class.
Raises: Exception
– An exception is raised if the client is not created by parl.connect(master_address) beforehand.