【问题标题】:Is there a way to disable video rendering in OpenAI gym while still recording it?有没有办法在录制的同时禁用 OpenAI 健身房中的视频渲染?
【发布时间】:2020-11-03 22:48:44
【问题描述】:

有没有办法在 OpenAI Gym 中禁用视频渲染,同时仍在录制?

当我使用 atari 环境和 Monitor 包装器时,默认行为是不渲染视频(视频仍被记录并保存到磁盘)。但是在MountainCarContinuous-v0CartPole-v0Pendulum-v0 等简单环境中,渲染视频是默认行为,我找不到如何禁用它(我仍然想将其保存到磁盘)。

我在服务器上运行我的作业,而官方建议的xvfb 解决方法不起作用。我看到很多人都遇到了问题,因为它与 nvidia 驱动程序发生冲突。我发现最常见的解决方案是重新安装 nvidia 驱动程序,但我无法这样做,因为我没有服务器的 root 访问权限。

【问题讨论】:

    标签: video openai-gym


    【解决方案1】:

    是的,您在 gym.wrappers.Monitor() 中有 video_callable=False kwarg

    import gym
    
    from gym import wrappers
    
    env = gym.make(env_name) # env_name = "Pendulum-v0"
    
    env = wrappers.Monitor(env, aigym_path, video_callable=False ,force=True)
    

    那么你想使用

    s = env.reset() # do this for initial time-step of each episode
    s_next, reward, done = env.step(a) # do this for every time-step with action 'a'
    

    运行您的剧集

    【讨论】:

    • NameError: name 'aigym_path' is not defined
    • aigym_path 是您希望保存渲染视频的目录,除非您将“video_callable”设置为 False。给它一个目录字符串,例如 '/home//bla/bla/savedFilms'
    【解决方案2】:

    在调用env.render() 之前调用此函数,因为在您第一次调用render() 之前不会导入渲染,并且此函数将替换默认的查看器构造函数。

    def disable_view_window():
        from gym.envs.classic_control import rendering
        org_constructor = rendering.Viewer.__init__
    
        def constructor(self, *args, **kwargs):
            org_constructor(self, *args, **kwargs)
            self.window.set_visible(visible=False)
    
        rendering.Viewer.__init__ = constructor
    
    

    【讨论】:

      猜你喜欢
      • 2019-10-16
      • 1970-01-01
      • 1970-01-01
      • 2022-10-08
      • 2018-10-10
      • 1970-01-01
      • 2019-02-05
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多