How to use rllib to conduct distributed training on multiple machines at the same time

How to use rllib to conduct distributed training on multiple machines at the same time. It seems that only Ray.train can do this, but not the trainer provided by Rllib? I have two high-performance algorithm servers, how to link together training.

Hi @zhangzhang,

You use tune. Keep in mind that in rllib with estandard synchronous rl algorithms the rollout of samples can be parallelized but the updating of the policy is not distributed that is done in a centralized process that collects the distributed samples.

Here is an example of using tune with rllib.

@ mannyv
Thank you,mannyyv. I currently hope that multiple machines can perform parallel policy updates at the same time. ray.trainer seems to support multiple machines to update policies at the same time, but rllib.trainer does not seem to support it. I don’t know how to solve this problem.

Hi @zhangzhang,

If you need distributed training for your problem then you can use one of these rllib algorithms: AC3, impala, a-ppo, dd-ppo, or apex-dqn.

What if I try to migrate distributed training code from ray.trainer to rllib.trainer? The algorithm I’m using is PPO

When I convert PPO to DDPPO in rllib for distributed training, it prompts: RuntimeError: No CUDA GPUs are available
Detail Info:
Failure # 1 (occurred at 2023-02-20_08-01-16)
Traceback (most recent call last):
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/tune/execution/”, line 989, in get_next_executor_event
future_result = ray.get(ready_future)
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/_private/”, line 105, in wrapper
return func(*args, **kwargs)
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/_private/”, line 2277, in get
raise value
ray.exceptions.RayActorError: The actor died because of an error raised in its creation task, e[36mray::DDPPOTrainerAddAsyn.init()e[39m (pid=14724, ip=, repr=DDPPOTrainerAddAsyn)
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/algorithms/ddppo/”, line 179, in init
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/algorithms/”, line 308, in init
super().init(config=config, logger_creator=logger_creator, **kwargs)
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/tune/trainable/”, line 157, in init
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/algorithms/ddppo/”, line 253, in setup
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/algorithms/”, line 418, in setup
self.workers = WorkerSet(
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/evaluation/”, line 171, in init
self._local_worker = self._make_worker(
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/evaluation/”, line 661, in _make_worker
worker = cls(
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/evaluation/”, line 613, in init
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/evaluation/”, line 1789, in _build_policy_map
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/policy/”, line 123, in create_policy
self[policy_id] = create_policy_for_framework(
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/utils/”, line 80, in create_policy_for_framework
return policy_class(observation_space, action_space, merged_config)
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/algorithms/ppo/”, line 50, in init
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/policy/”, line 81, in init
model, dist_class = self._init_model_and_dist_class()
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/policy/”, line 446, in _init_model_and_dist_class
model = ModelCatalog.get_model_v2(
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/ray/rllib/models/”, line 622, in get_model_v2
instance = model_cls(
File “ray_adapter/”, line 359, in init
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/torch/nn/modules/”, line 927, in to
return self._apply(convert)
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/torch/nn/modules/”, line 579, in _apply
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/torch/nn/modules/”, line 579, in _apply
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/torch/nn/modules/”, line 579, in _apply
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/torch/nn/modules/”, line 602, in _apply
param_applied = fn(param)
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/torch/nn/modules/”, line 925, in convert
return, dtype if t.is_floating_point() or t.is_complex() else None, non_blocking)
File “/opt/conda/envs/rl_decision/lib/python3.8/site-packages/torch/cuda/”, line 217, in _lazy_init
RuntimeError: No CUDA GPUs are available