lit_sb3.vec_env.subproc_vec_env
source module lit_sb3.vec_env.subproc_vec_env
Classes
-
SubprocVecEnv — Creates a multiprocess vectorized wrapper for multiple environments, distributing each environment to its own.
source class SubprocVecEnv(env_fns: list[Callable[[], gym.Env]], start_method: str | None = None)
Bases : VecEnv
Creates a multiprocess vectorized wrapper for multiple environments, distributing each environment to its own.
process, allowing significant speed up when the environment is computationally complex.
For performance reasons, if your environment is not IO bound, the number of environments should not exceed the number of logical cores on your CPU.
.. warning::
Only 'forkserver' and 'spawn' start methods are thread-safe,
which is important when TensorFlow sessions or other non thread-safe
libraries are used in the parent (see issue #217). However, compared to
'fork' they incur a small start-up cost and have restrictions on
global variables. With those methods, users must wrap the code in an
``if __name__ == "__main__":`` block.
For more information, see the multiprocessing documentation.
Parameters
-
env_fns : list[Callable[[], gym.Env]] — Environments to run in subprocesses
-
start_method : str | None — method used to start the subprocesses. Must be one of the methods returned by multiprocessing.get_all_start_methods(). Defaults to 'forkserver' on available platforms, and 'spawn' otherwise.
Methods
-
has_attr — Check if an attribute exists for a vectorized environment. (see base class).
-
get_attr — Return attribute from vectorized environment (see base class).
-
set_attr — Set attribute inside vectorized environments (see base class).
-
env_method — Call instance methods of vectorized environments.
-
env_is_wrapped — Check if worker environments are wrapped with a given wrapper.
source method SubprocVecEnv.step_async(actions: np.ndarray) → None
source method SubprocVecEnv.step_wait() → VecEnvStepReturn
source method SubprocVecEnv.reset() → VecEnvObs
source method SubprocVecEnv.close() → None
source method SubprocVecEnv.get_images() → Sequence[np.ndarray | None]
source method SubprocVecEnv.has_attr(attr_name: str) → bool
Check if an attribute exists for a vectorized environment. (see base class).
source method SubprocVecEnv.get_attr(attr_name: str, indices: VecEnvIndices = None) → list[Any]
Return attribute from vectorized environment (see base class).
source method SubprocVecEnv.set_attr(attr_name: str, value: Any, indices: VecEnvIndices = None) → None
Set attribute inside vectorized environments (see base class).
source method SubprocVecEnv.env_method(method_name: str, *method_args, indices: VecEnvIndices = None, **method_kwargs) → list[Any]
Call instance methods of vectorized environments.
source method SubprocVecEnv.env_is_wrapped(wrapper_class: type[gym.Wrapper], indices: VecEnvIndices = None) → list[bool]
Check if worker environments are wrapped with a given wrapper.