Click anywhere to close

Running Multiple Retro Environments

Due to constraints on Retro, it is not possible to run multiple retro environments in the same process. This restriction will will cause creating multiple environments this to raise the following error:

import retro

env1 = retro.make( game='SonicTheHedgehog2-Genesis', state='MetropolisZone.Act1' )
env2 = retro.make( game='SonicTheHedgehog2-Genesis', state='MetropolisZone.Act2' )
RuntimeError: Cannot create multiple emulator instances per process

Due to this restriction, it can be hard to do parallel joint training of agents. Thankfully the retrowrapper project makes it very easy to run environments as subprocess and interact with them as if they were a standard gym environment.

Using retrowrapper is easy. First install via pip:

pip install retrowrapper

Then simply import and create your environments.

import retrowrapper

env1 = retrowrapper.RetroWrapper(
    game='SonicTheHedgehog2-Genesis',
    state='MetropolisZone.Act1'
)
env2 = retrowrapper.RetroWrapper(
    game='SonicTheHedgehog2-Genesis',
    state='MetropolisZone.Act2'
)

Now you should no longer get the “Cannot create multiple emulator instances per process” error.

The retrowrapper library also allows you to specify a custom make function, this is useful when you want to apply custom wrappers to the environment. It is also useful during the retro-contest, allowing you to use the retro_contest.local make function that applies the contest wrappers.

To use retrowrapper with the retro_contest make function you simply need to set it before create your environments.

import retrowrapper
from retro_contest.local import make

retrowrapper.set_retro_make( make )

env1 = retrowrapper.RetroWrapper(
    game='SonicTheHedgehog2-Genesis',
    state='MetropolisZone.Act1'
)
env2 = retrowrapper.RetroWrapper(
    game='SonicTheHedgehog2-Genesis',
    state='MetropolisZone.Act2'
)

The environments are now created using the retro_contest.local make function.

Recent Posts

The future is multiplayer
Technology
posted: November 05, 2026
How we stay productive in the claude code era Two things always mattered for engineering productivity, but Claude Code makes them matter a lot more: managing many projects at once, and iterating as fast as possible.
Technology
posted: April 14, 2026
Not Enough People Are Talking About AI-Enabled Disruption The real winners of the AI wave will be people who figure out how to disrupt old industries by building AI-first companies.
Technology
posted: February 24, 2026
Engineering Culture at Hi Finance What we're building at hi finance, why we're building it, and the engineering values driving how we build it. Plus, we're hiring a Founding Engineer.
Technology
posted: February 16, 2026
AI Doesn't Change the Job of a Software Engineer Writing code is not, and has never been, the main job of a Software Engineer
Technology
posted: February 06, 2026