We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5d13488 commit f121701Copy full SHA for f121701
torchrl/envs/libs/gym.py
@@ -1016,7 +1016,14 @@ def _build_env(
1016
raise err
1017
env = super()._build_env(env, pixels_only=pixels_only, from_pixels=from_pixels)
1018
if num_envs > 0:
1019
- env = self._async_env([CloudpickleWrapper(lambda: env)] * num_envs)
+ try:
1020
+ env = self._async_env([CloudpickleWrapper(lambda: env)] * num_envs)
1021
+ except RuntimeError:
1022
+ # It would fail if the environment is not pickable. In that case,
1023
+ # delegating environment instantiation to each subprocess as a fallback.
1024
+ env = self._async_env(
1025
+ [lambda: self.lib.make(env_name, **kwargs)] * num_envs
1026
+ )
1027
self.batch_size = torch.Size([num_envs, *self.batch_size])
1028
return env
1029
0 commit comments