habitat.core.vector_env

class habitat.core.vector_env.ThreadedVectorEnv(make_env_fn: Callable[..., habitat.core.env.Env] = <function _make_env_fn>, env_fn_args: Tuple[Tuple] = None, auto_reset_done: bool = True, multiprocessing_start_method: str = 'forkserver')[source]

Provides same functionality as VectorEnv, the only difference is it runs in a multi-thread setup inside a single process. VectorEnv runs in a multi-proc setup. This makes it much easier to debug when using VectorEnv because you can actually put break points in the environment methods. It should not be used for best performance.

class habitat.core.vector_env.VectorEnv(make_env_fn: Callable[..., habitat.core.env.Env] = <function _make_env_fn>, env_fn_args: Tuple[Tuple] = None, auto_reset_done: bool = True, multiprocessing_start_method: str = 'forkserver')[source]

Vectorized environment which creates multiple processes where each process runs its own environment. All the environments are synchronized on step and reset methods.

Parameters
  • make_env_fn – function which creates a single environment. An environment can be of type Env or RLEnv

  • env_fn_args – tuple of tuple of args to pass to the make_env_fn.

  • auto_reset_done – automatically reset the environment when done. This functionality is provided for seamless training of vectorized environments.

  • multiprocessing_start_method – the multiprocessing method used to spawn worker processes. Valid methods are {'spawn', 'forkserver', 'fork'} 'forkserver' is the recommended method as it works well with CUDA. If 'fork' is used, the subproccess must be started before any other GPU useage.

async_step(actions: List[int]) → None[source]

Asynchronously step in the environments.

Parameters

actions – actions to be performed in the vectorized envs.

call(function_names: List[str], function_args_list: Optional[List[Any]] = None) → List[Any][source]

Calls a list of functions (which are passed by name) on the corresponding env (by index).

Parameters
  • function_names – the name of the functions to call on the envs.

  • function_args_list – list of function args for each function. If provided, len(function_args_list) should be as long as len(function_names).

Returns

result of calling the function.

call_at(index: int, function_name: str, function_args: Optional[List[Any]] = None) → Any[source]

Calls a function (which is passed by name) on the selected env and returns the result.

Parameters
  • index – which env to call the function on.

  • function_name – the name of the function to call on the env.

  • function_args – optional function args.

Returns

result of calling the function.

property num_envs
Returns

number of individual environments.

pause_at(index: int) → None[source]

Pauses computation on this env without destroying the env. This is useful for not needing to call steps on all environments when only some are active (for example during the last episodes of running eval episodes).

Parameters

index – which env to pause. All indexes after this one will be shifted down by one.

render(mode: str = 'human', *args, **kwargs) → Optional[numpy.ndarray][source]

Render observations from all environments in a tiled image.

reset()[source]

Reset all the vectorized environments

Returns

list of outputs from the reset method of envs.

reset_at(index_env: int)[source]

Reset in the index_env environment in the vector.

Parameters

index_env – index of the environment to be reset

Returns

list containing the output of reset method of indexed env.

resume_all() → None[source]

Resumes any paused envs.

step(actions: List[int])[source]

Perform actions in the vectorized environments.

Parameters

actions – list of size _num_envs containing action to be taken in each environment.

Returns

list of outputs from the step method of envs.

step_at(index_env: int, action: int)[source]

Step in the index_env environment in the vector.

Parameters
  • index_env – index of the environment to be stepped into

  • action – action to be taken

Returns

list containing the output of step method of indexed env.

wait_step() → List[habitat.core.simulator.Observations][source]

Wait until all the asynchronized environments have synchronized.