Open
Description
I am trying to train a model using PPO, and the stable-baseline3[extra] library is also installed.
The issue occurs because the StochasticFrameSkip object does not have an action_space attribute, leading to an AttributeError when used in a multiprocessing environment with SubprocVecEnv. This error is triggered when wrappers like WarpFrame try to access the action_space during environment creation. Additionally, there is a deprecation warning from gymnasium about directly accessing env.action_space, recommending the use of env.unwrapped.action_space or env.get_wrapper_attr('action_space'). This causes the subprocess to fail, resulting in a ConnectionResetError.
/home/alarm/retro/env/lib/python3.9/site-packages/gymnasium/core.py:311: UserWarning: WARN: env.action_space to get variables from other wrappers is deprecated and will be removed in v1.0, to get this variable you can do `env.unwrapped.action_space` for environment variables or `env.get_wrapper_attr('action_space')` that will search the reminding wrappers.
logger.warn(
Process ForkServerProcess-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
self.run()
File "/usr/local/lib/python3.9/multiprocessing/process.py", line 108, in run
self._target(*self._args, **self._kwargs)
File "/home/alarm/retro/env/lib/python3.9/site-packages/stable_baselines3/common/vec_env/subproc_vec_env.py", line 24, in _worker
env = env_fn_wrapper.var()
File "/home/alarm/retro/test.py", line 98, in make_env
env = wrap_deepmind_retro(env)
File "/home/alarm/retro/test.py", line 83, in wrap_deepmind_retro
env = WarpFrame(env)
File "/home/alarm/retro/env/lib/python3.9/site-packages/stable_baselines3/common/atari_wrappers.py", line 188, in __init__
gym.ObservationWrapper.__init__(self, env)
File "/home/alarm/retro/env/lib/python3.9/site-packages/gym/core.py", line 215, in __init__
self.action_space = self.env.action_space
File "/home/alarm/retro/env/lib/python3.9/site-packages/gymnasium/core.py", line 315, in __getattr__
return getattr(self.env, name)
AttributeError: 'StochasticFrameSkip' object has no attribute 'action_space'
Traceback (most recent call last):
File "/home/alarm/retro/test.py", line 124, in <module>
main()
File "/home/alarm/retro/test.py", line 101, in main
venv = VecTransposeImage(VecFrameStack(SubprocVecEnv([make_env] * 1), n_stack=40))
File "/home/alarm/retro/env/lib/python3.9/site-packages/stable_baselines3/common/vec_env/subproc_vec_env.py", line 111, in __init__
observation_space, action_space = self.remotes[0].recv()
File "/usr/local/lib/python3.9/multiprocessing/connection.py", line 250, in recv
buf = self._recv_bytes()
File "/usr/local/lib/python3.9/multiprocessing/connection.py", line 414, in _recv_bytes
buf = self._recv(4)
File "/usr/local/lib/python3.9/multiprocessing/connection.py", line 379, in _recv
chunk = read(handle, remaining)
ConnectionResetError: [Errno 104] Connection reset by peer
System information
- [Operating system]
Raspberry pi 5 8 gb Linux A port of debian Bookworm with the Raspberry Pi Desktop (64 bit)
Linux pi5 6.6.31+rpt-rpi-2712 SMP PREEMPT Debian 1:6.6.31-1+rpt1 (2024-05-29) aarch64 GNU/Linux - [Python version]
3.9.19 - [Gym Retro version]
Compiled from source code
Metadata
Metadata
Assignees
Labels
No labels