# Can not use two agents of PPO

**URL:** <https://discuss.ray.io/t/can-not-use-two-agents-of-ppo/5302>\
**Category:** RLlib\
**Created:** [March 4, 2022, 4:55pm UTC](https://discuss.ray.io/t/can-not-use-two-agents-of-ppo/5302 "2022-03-04T16:55:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Liam](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/liam/32/2242_2.png) [@Liam](https://discuss.ray.io/u/Liam)\
**Post date:** [March 4, 2022, 4:55pm UTC](https://discuss.ray.io/t/can-not-use-two-agents-of-ppo/5302/1 "2022-03-04T16:55:18Z")

</div>

```
    register_env(paramfile['env'], _env)
    register_custom_model(paramfile['model'])
    ray.init(num_cpus=1,num_gpus=0) 

    agent1= ppo.PPOTrainer(config=paramfile, env=paramfile['env'])

    agent2= ppo.PPOTrainer(config=paramfile, env=paramfile['env'])

```

Would like to load two PPO agents to load two different trained networks with different structures. But the error is:

\*\*\* mlagents\_envs.exception.UnityWorkerInUseException: Couldn’t start socket communication because worker number 0 is still in use. You may need to manually close a previously opened environment or use a different worker number.

Could you help to show how to use a different worker number

---

<div class="post-metadata">

**Author:** ![avnishn](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/avnishn/32/1544_2.png) [@avnishn](https://discuss.ray.io/u/avnishn)\
**Post date:** [March 16, 2022, 1:51am UTC](https://discuss.ray.io/t/can-not-use-two-agents-of-ppo/5302/2 "2022-03-16T01:51:48Z")

</div>

This seems like a detail with regards to your environment and not necessarily RLlib.

Something that you could do here is follow the rllib examples on our github and website to figure out how to pass parameters to your environment upon its creation (search for the env config)

> <https://github.com/ray-project/ray/blob/499c242f0fcb8503b0f2f8ff6335d02f541810a9/rllib/examples/custom_env.py#L162>
