Comments (5)
Hello! I was trying to run multiple gym-super-mario-bros environments in separate threads today, and it didn't work (Lots of "invalid OPcode"). Apparently, this is something you have been thinking about. I hope you will try to fix this. For my use case, multiple processes may be an option too, but my first choice was threading. Running multiple instances in a single thread is less interesting, as the main point is to use the power of multiple CPU cores. I am intending to use this for more efficient sampling of observations received through play with a given policy. I sample observations only with a low probability (dependent on the accumulated reward), so right now I believe the sampling is bound by the emulator, not by the harddrive. (And definitely not by the memory, if/when I move all operations into RAM).
Update: I made my frame sampling work with multiprocessing (Pool and map). This was with a rudimentary stochastic policy, not with a deep learning-based policy. I don't know if running multiple tensorflow-gpu instances in independent processes is even possible. It would be better to share one instance, as they will be running the same policy. I guess sharing a tensorflow instance is much easier using threads than using processes.
from nes-py.
Sharing data will certainly be much easier with threads opposed to processes; however, this is the current issue with the C++ codebase here that uses a functional decomposition instead of a proper object oriented design. I've attempted to refactor, but the change is nontrivial and has eaten quite a lot of my time as the C++ is not my code to begin with.
TensorFlow can run in multiple processes, but you'll need an explicitly dedicated GPU for each process or else to just use the CPU. I use this config to train multiple models (independently) on a single node equipped with multiple GPUs using the linux tool screen
. To share a policy, you'd need some form of synchronization mechanism between the processes. I've seen Redis used by OpenAI to handle this sort of issue in their work, though this is obviously for a massively parallel system running across hundreds of CPU cores. Alternatively, you can probably use TF callbacks and some form of mutex/semaphore.
Ultimately, I'd suggest a multi-processing approach as python threads are a rather limited form of parallelism. However, feel free to dig into the C++ to refactor out the poor data management and support threads! A change like that would likely solve the remaining bugs in this codebase, i.e., #36
from nes-py.
from nes-py.
I feel the same way!
from nes-py.
Parallelism of all forms is now supported by the master branch. Code will release under version 3.0.0 sometime today. Closing issue
from nes-py.
Related Issues (20)
- Helpme
- Continuous prediction of action by agent does not result in the desired action in the Env HOT 1
- super-mario bug help me
- I cannot reproduce results for an agent. What is going on? HOT 1
- How to support ROM mapper number which is not supported now HOT 2
- Is nes-py available in Anaconda environment? HOT 2
- Access information not stored in RAM HOT 1
- Can the simulator output audio info? HOT 1
- Nes-py not installing on Ubuntu HOT 2
- Can't compile it in m1 mac HOT 2
- Hold button HOT 1
- 'def _will_reset(self)' description is wrong in the wiki
- Can't install on macOS 12.5
- update to gym v26
- ValueError: ROM header zero fill bytes are not zero. HOT 1
- Failed to install 'nes-py' HOT 5
- Improperly formatted ROMs
- It seems that render() works even inside thread. HOT 1
- An error occurs
- env.reset() returns TypeError: JoypadSpace.reset() got an unexpected keyword argument 'seed' error while using DummyVecEnv wrapper
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nes-py.