question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

SubprocVecEnv not working

See original GitHub issue

I’m trying to use SubprocVecEnv to initialize multiple instances of one environment to use in ACKTR and A2C, however, there seem to be problems with SubprocVecEnv. Following this code, the following happens:

def make_env():
    env = gym.make('Test-v0')
    return env

env = gym.make('Test-v0') #Works, env initialization message is printed
env = make_env() #Works, env initialization message is printed
env = SubprocVecEnv([make_env]) #Doesn't work, code gets stuck

Meaning, env creation through the function works fine, the same goes for manual creation, however, when SubprocVecEnv is called the code gets stuck, nothing seems to happen and it doesn’t stop running, nor does the environment get created.

I tried calling manually env = SubprocVecEnv([make_env]) and it yields a strange error:

env = SubprocVecEnv([make_env]) Traceback (most recent call last):

File “<ipython-input-8-427e992f56b1>”, line 1, in <module> env = SubprocVecEnv([make_env])

File “c:\users\x\baselines\baselines\common\vec_env\subproc_vec_env.py”, line 58, in init observation_space, action_space = self.remotes[0].recv()

File “D:\Programs\Anaconda3\lib\multiprocessing\connection.py”, line 250, in recv buf = self._recv_bytes()

File “D:\Programs\Anaconda3\lib\multiprocessing\connection.py”, line 321, in _recv_bytes raise EOFError

EOFError

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:5
  • Comments:9

github_iconTop GitHub Comments

5reactions
abhiskkcommented, Oct 30, 2018

It does use SubprocVecEnv, I just make a dummy call to custom_atari_env before making a call to the original make_atari_env.

env = custom_atari_env('BreakoutNoFrameskip-v4', num_env=4, seed=42)
env = make_atari_env('PongNoFrameskip-v4', num_env=4, seed=42)

The call to custom_atari_env I think sets something up in the background and the make_atari_env does not throw an error after that.

0reactions
pzhokhovcommented, Jan 29, 2019

@Coronon could you provide the code you are running and error stacktrace? The baselines code has changed quite a bit since the issue was opened; it would be helpful to have a recent stacktrace.

Read more comments on GitHub >

github_iconTop Results From Across the Web

SubprocVecEnv example code does not work #155 - GitHub
I am opening a new issue because #40 does not match, and is a bit messy (and closed). Describe the bug Subprocess creation...
Read more >
SubprocVecEnv not working with Custom Env (Stable Baselines
I've started the code as follows: class MyEnv(gym.Env): .... But if I try to use SubprocVecEnv to accelerate the learning process using all ......
Read more >
stable_baselines.common.vec_env.subproc_vec_env
[docs]class SubprocVecEnv(VecEnv): """ Creates a multiprocess vectorized wrapper for ... For performance reasons, if your environment is not IO bound, ...
Read more >
Python stable_baselines.common.vec_env.SubprocVecEnv ...
This page shows Python examples of stable_baselines.common.vec_env.SubprocVecEnv.
Read more >
Stable Baselines Tutorial - Multiprocessing of environments
from stable_baselines.common.vec_env import DummyVecEnv, SubprocVecEnv ... otherwise, you may have memory issues when running a lot of experiments
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found