简体   繁体   English

Windows 上的 OpenAI Gym Atari

[英]OpenAI Gym Atari on Windows

I'm having issues installing OpenAI Gym Atari environment on Windows 10. I have successfully installed and used OpenAI Gym already on the same system.我在 Windows 10 上安装 OpenAI Gym Atari 环境时遇到问题。我已经在同一系统上成功安装并使用了 OpenAI Gym。

It keeps tripping up when trying to run a makefile.尝试运行 makefile 时,它​​会一直跳闸。

I am running the command pip install gym[atari]我正在运行命令pip install gym[atari]

Here is the error:这是错误:

在此处输入图片说明

and here is what I currently have on my system... cmake and make are both clearly installed.这是我目前在我的系统上的... cmakemake都清楚地安装。

在此处输入图片说明

A while ago I have created a fork with Windows support (devs of original repository do not merge or even comment PRs and issues).不久前,我创建了一个支持 Windows 的 fork(原始存储库的开发人员不会合并甚至评论 PR 和问题)。 It does not require neither MSYS/Cygwin nor CMake or Zlib.它既不需要 MSYS/Cygwin,也不需要 CMake 或 Zlib。

To simply install atari-py wheels (binaries) use this command:要简单地安装atari-py轮子(二进制文件),请使用以下命令:

pip install -f https://github.com/Kojoley/atari-py/releases atari_py

If you have any distutils supported compiler you can install from sources:如果你有任何支持distutils编译器,你可以从源代码安装:

pip install git+https://github.com/Kojoley/atari-py.git

Test your installation with a simple example:用一个简单的例子测试你的安装:

import gym
env = gym.make('SpaceInvaders-v0')
env.reset()
for _ in range(1000):
    env.step(env.action_space.sample())
    env.render('human')
env.close()  # https://github.com/openai/gym/issues/893

If your got a 'scrambled' output that's most likely because your gym is outdated .如果您得到“混乱”的输出,那很可能是因为您的gym已经过时了

This is not fully tested, because I don't remember exactly what I did, but currently I have openAI gym running with all the atari games set up and displaying, and also matplotlib plots, all while using ubuntu on windows (WSL).这没有经过全面测试,因为我不记得我做了什么,但目前我有 openAI 健身房运行,所有 atari 游戏设置和显示,还有 matplotlib 图,同时在 windows (WSL) 上使用 ubuntu。 In fact I have sublimetext3 and spider working too.事实上,我也有 sublimetext3 和蜘蛛工作。

So take these as a guide, but I don't have "clean" environment to test them on.所以以这些为指导,但我没有“干净”的环境来测试它们。

First, in Windows, Google "xming" (x11 server) and download from sourceforge / install / run.首先,在Windows 中,谷歌“xming”(x11 服务器)并从sourceforge 下载/安装/运行。 This is what makes it all possible.这就是使这一切成为可能的原因。

Now in WSL bash install the display stuff to work with xming现在在 WSL bash 中安装显示内容以与 xming 一起使用

sudo apt-get install x11-apps
export DISPLAY=localhost:0.0 
nano ~/.bashrc  #(add  export DISPLAY=localhost:0.0   at the end. Ctrl+X to exit/save)
sudo apt-get install gnome-calculator #will get you GTK

Now in WSL bash install Anaconda.现在在 WSL bash 中安装 Anaconda。 this will involve downloading the .sh file (eg with curl -O "[the http link to latest anaconda]" and running it with bash [the file].sh . Don't use sudo when installing Anaconda.这将涉及下载 .sh 文件(例如使用 curl -O“[最新 anaconda 的 http 链接]”并使用bash [the file].sh运行它。安装 Anaconda 时不要使用 sudo。

With anaconda installed, close WSL, and restart it.安装 anaconda 后,关闭 WSL,然后重新启动它。 Now make an environment and activate it现在创建一个环境并激活它

conda create -n gym python=3.5 anaconda
source activate gym

Now get the gym repo现在得到健身房回购

git clone https://github.com/openai/gym.git
cd gym

Now install these gym dependencies mentioned on openai gym repo现在安装 openai 健身房 repo 上提到的这些健身房依赖项

apt-get install -y python-numpy python-dev cmake zlib1g-dev libjpeg-dev xvfb libav-tools xorg-dev python-opengl libboost-all-dev libsdl2-dev swig

Now install libgcc with conda现在用 conda 安装 libgcc

conda install libgcc

Now build gym现在建健身房

pip install -e '.[all]'

That's basically it.基本上就是这样。 make sure Xming is running on windows, and in WSL type gnome-calculator, and it should bring up the calculator.确保 Xming 在 Windows 上运行,并在 WSL 中输入 gnome-calculator,它应该会调出计算器。 if it doesn't, keep working on the display side.如果没有,请继续在显示端工作。 If it does, try running some of the agents in the gym examples folder.如果是,请尝试运行 Gym 示例文件夹中的一些代理。

I may have missed a couple extra dependencies along the way, but these would have been things I figured out based on error messages.在此过程中,我可能错过了一些额外的依赖项,但这些都是我根据错误消息发现的。

Here's the pic to keep you motivated:这是让你保持动力的图片: 在此处输入图片说明

EDIT: Today I ran the following command which installed Qt5 as the back end, and matplotlib is working fine with Qt5Agg as the back end (vs TkAgg).编辑:今天我运行了以下命令,该命令将 Qt5 安装为后端,并且 matplotlib 与 Qt5Agg 作为后端(与 TkAgg)一起工作正常。 This may be helpful if you're running some thing else on WSL which needs Qt5如果您在 WSL 上运行其他需要 Qt5 的东西,这可能会有所帮助

sudo apt-get update && sudo apt-get install qtbase5-dev

Also, to find your matplotlibrc, and command prompt type: python import matplotlib print(matplotlib.matplotlib_fname()) quit()另外,要找到你的 matplotlibrc 和命令提示符类型: python import matplotlib print(matplotlib.matplotlib_fname()) quit()

Please note that there is NO GPU SUPPORT on ubuntu for windows.请注意,windows 的 ubuntu 上没有 GPU 支持 This is the top requested feature at uservoice, yet MS has it on "backlog".这是 uservoice 最需要的功能,但 MS 把它放在“积压”上。 If you're interested, vote here如果您有兴趣,请在这里投票

I ended up installing Bash on Ubuntu on Windows and using it to run the OpenAI Gym / Atari environment.我最终在 Windows 上的 Ubuntu 上安装了 Bash,并使用它来运行 OpenAI Gym / Atari 环境。 OpenAI Gym has very limited support for Windows at the moment. OpenAI Gym 目前对 Windows 的支持非常有限。

I encountered that gym now requires later version v0.1.4 of atari-py than any of other cloned repos.我发现gym现在需要比任何其他克隆存储库更高的atari-py版本。

Thanks to Nikita Kniazev - I ported his Windows edits to latest code from openai/atari-py and got gym working.感谢 Nikita Kniazev - 我将他的 Windows 编辑移植到 openai/atari-py 的最新代码,并让gym工作。

Use: pip install git+https://github.com/Kojoley/atari-py.git使用: pip install git+https://github.com/Kojoley/atari-py.git

I had the same issue with the atari-py environment.我在atari-py环境中遇到了同样的问题。 Then I followed the steps in the Openai GitHub and then it worked.然后我按照Openai GitHub 中的步骤操作,然后就成功了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM