# Training ray.rllib algorithm with vectorized environments

**URL:** <https://discuss.ray.io/t/training-ray-rllib-algorithm-with-vectorized-environments/4958>\
**Category:** RLlib\
**Created:** [February 7, 2022, 11:56am UTC](https://discuss.ray.io/t/training-ray-rllib-algorithm-with-vectorized-environments/4958 "2022-02-07T11:56:14Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![sai\_lalith\_Polawar](https://sea2.discourse-cdn.com/flex020/user_avatar/discuss.ray.io/sai_lalith_polawar/32/2094_2.png) [@sai\_lalith\_Polawar](https://discuss.ray.io/u/sai_lalith_Polawar)\
**Post date:** [February 7, 2022, 11:56am UTC](https://discuss.ray.io/t/training-ray-rllib-algorithm-with-vectorized-environments/4958/1 "2022-02-07T11:56:14Z")

</div>

I have created a custom vectorized environment using static method as mentioned in [https://stackoverflow.com/q/70988560/18120335](https://stackoverflow.com/q/70988560/18120335) and the question is how to use the return of that static method to train an algorithm. Is there any option to pass our own vec env to algorithms in ray.rllib? If this is not used to train any algorithm then what is this static method used for?

---

<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:** [February 8, 2022, 1:22am UTC](https://discuss.ray.io/t/training-ray-rllib-algorithm-with-vectorized-environments/4958/2 "2022-02-08T01:22:28Z")

</div>

If your environment is a gym environment, then you actually shouldn’t need to manually need to vectorize your gym environment. RLlib experiments automatically vectorize the gym environment that is passed.

To see an example of using a custom gym environment with our launchers, see this example:

> <https://github.com/ray-project/ray/blob/ee1711fe418e44818ff791b266cd9dea42a65957/rllib/examples/custom_env.py#L155>

:
