Giter Site home page Giter Site logo

Comments (6)

Kautenja avatar Kautenja commented on May 29, 2024

Just to clarify, by done you mean the done flag is set to True for all the environments simultaneously? If this is the case, could you provide a simple code snippet that reproduces the issue?

My thought is that this results from the way the communication pipeline between the emulator and the Python client is setup. The Unix pipe name is setup once per Python shell session which certainly would cause an issue when parallelizing internally through either the multiprocessing or the threading package. It's a simple fix, but I'd like to have some code to reproduce the problem so I can be sure the subsequent solution resolves the issue.

from gym-super-mario-bros.

Kautenja avatar Kautenja commented on May 29, 2024

I've implemented the fix and written some tests in the tools directory. Version 1.1.2 should resolve any problems with the threading or multiprocessing packages and is live now on PyPi. Closing the issue for now. If you find that this doesn't resolve your issue please comment and I'll reopen it.

from gym-super-mario-bros.

jcwleo avatar jcwleo commented on May 29, 2024

@Kautenja https://gist.github.com/jcwleo/f5daa30a40ea8ae14190a02bc7425236
this is simple code. thank you.

from gym-super-mario-bros.

jcwleo avatar jcwleo commented on May 29, 2024

@Kautenja i updated gym-super-mario-bros 1.1.2. but still appear same issue :(

from gym-super-mario-bros.

Kautenja avatar Kautenja commented on May 29, 2024

ah I see the problem now from the sample. Calling make from the parent process results in all the 4 environments having the same PID and thread name and thus the pipe to the emulator is the same for all of them. It appears that standard Atari Envs work with your configuration so I'll take a look at their source to check how they initialize their pipes to Stella. For now, if you can refactor your code to call make from within the subprocess, it will work. i.e.

import gym_super_mario_bros
import multiprocessing as mp


class Env(object):
    def __init__(self, env):
        self.env = env
        self.env.reset()
        self.done = False

    def run(self):
        for step in range(5000):
            if self.done:
                state = self.env.reset()
                self.done = False
            state, reward, self.done, info = self.env.step(self.env.action_space.sample())


def runner():
    env = Env(gym_super_mario_bros.make('SuperMarioBros-v0'))
    env.run()


procs = []

for idx in range(4):
    proc = mp.Process(target=runner)
    proc.start()
    procs.append(proc)

for proc in procs:
    proc.join()

However, I'll likely have the new fix out within the next couple of hours so stay posted. Reopening issue.

from gym-super-mario-bros.

Kautenja avatar Kautenja commented on May 29, 2024

Alright so the named pipes now use the uuid package to ensure that the pipe name is unique irrespective of where a new environment is initialized (using host ID and current time). Version 1.1.3 on PyPi is live with these changes and works on both your and my example codes. Please report back if the issue somehow still persists on your end though. Closing issue.

from gym-super-mario-bros.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.