OpenAI Gym Atari on Windows

2019-01-21 05:08发布

问题:

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.

It keeps tripping up when trying to run a makefile.

I am running the command 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.

回答1:

A while ago I have created a fork with Windows support (devs of original repository do not merge or even comment PRs and issues). It does not require neither MSYS/Cygwin nor CMake or Zlib.

To simply install atari-py wheels (binaries) use this command:

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

If you have any distutils supported compiler you can install from sources:

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.



回答2:

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). In fact I have sublimetext3 and spider working too.

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. This is what makes it all possible.

Now in WSL bash install the display stuff to work with 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. 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.

With anaconda installed, close WSL, and restart it. 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

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 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. if it doesn't, keep working on the display side. If it does, try running some of the agents in the gym examples folder.

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). This may be helpful if you're running some thing else on WSL which needs 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()

Please note that there is NO GPU SUPPORT on ubuntu for windows. This is the top requested feature at uservoice, yet MS has it on "backlog". If you're interested, vote here



回答3:

I ended up installing Bash on Ubuntu on Windows and using it to run the OpenAI Gym / Atari environment. OpenAI Gym has very limited support for Windows at the moment.



回答4:

follow this steps:

1.install xming for windows10 from here: https://sourceforge.net/projects/xming/

2.open bash and type this command: sudo apt-get install python-pip

3.sudo 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

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

if you have not installed git allready install it with following command: sudo apt-get install git

5.cd gym

6.pip install -e '.[all]'

7.then set an environment variable with the following command you have to do it every time you open bash window: export DISPLAY=:0

8.now open python and try to run atari it should work



回答5:

I encountered that gym now requires later version v0.1.4 of atari-py than any of other cloned repos.

Thanks to Nikita Kniazev - I ported his Windows edits to latest code from openai/atari-py and got gym working.

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