GithubHelp home page GithubHelp logo

Comments (2)

robinhenry avatar robinhenry commented on June 15, 2024

@diegofz I believe this is due to a known issue when using python multiprocessing on Windows (e.g., see here).

gym-anm uses multiprocessing to render the environment in your browser: a local server is started in the background and communicates with the main thread using websockets to update the visualization in real-time.

In order to get the rendering to work with your setup (you shouldn't have this problem if you remove the env.render() statement), all you need to do is to guard the entry point of your code with an if __name__ == '__main__' statement.

For example, you can rewrite the example given in the Quickstart section:

import gym
import time

env = gym.make('gym_anm:ANM6Easy-v0')
o = env.reset()

for i in range(100):
    a = env.action_space.sample()
    o, r, done, info = env.step(a)
    env.render()
    time.sleep(0.5)  # otherwise the rendering is too fast for the human eye.
env.close()

as follows:

import gym
import time

def run():
    env = gym.make('gym_anm:ANM6Easy-v0')
    o = env.reset()
    
    for i in range(100):
        a = env.action_space.sample()
        o, r, done, info = env.step(a)
        env.render()
        time.sleep(0.5)  # otherwise the rendering is too fast for the human eye.
    env.close()

if __name__ == '__main__':
    run()

and that should do the trick. It worked for me on my Windows virtual machine.

Unfortunately I'm not sure there's a simple solution to get that to work in Jupyter Notebooks or in Collab. I would recommend you don't render the environment if you're using either of these tools.

Hope that helps!

from gym-anm.

sifatron avatar sifatron commented on June 15, 2024

I have been having rendering issues, where nothing shows up, just a blank screen.
Based on this closed issue, I switched from windows 10 to windows 11. Also switched from Jupyter notebook to pycharm. And I am running the code you shared. I am still getting a blank screen, How can I fix it? Both machines have decent processors and gpu capabilities.

from gym-anm.

Related Issues (10)

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.