openai / atari-py

A packaged and slightly-modified version of https://github.com/bbitmaster/ale_python_interface
GNU General Public License v2.0
367 stars 183 forks source link

Problem in Google colab with "Breakout" game in OpenAI Gym (ROM missing) #83

Closed amitjo closed 2 years ago

amitjo commented 3 years ago

Browser: Chrome

Creating env for "Breakout" game from OpenAI Gym is giving problem in Googlw colab. Following is the error message that pops up.

Note: This problem seems to be a recent issue. It was a working code till 2 days back and suddenly started giving problems.

############################################################################################

Exception Traceback (most recent call last) in () 1 if name == 'main': 2 ----> 3 env = gym.make('Breakout-v0') 4 load_checkpoint = False 5 agent = Agent(gamma=0.99, epsilon=1.0, alpha=0.000025, input_dims=(180,160,4),

4 frames /usr/local/lib/python3.7/dist-packages/atari_py/games.py in get_game_path(game_name) 18 path = os.path.join(_games_dir, game_name) + ".bin" 19 if not os.path.exists(path): ---> 20 raise Exception('ROM is missing for %s, see https://github.com/openai/atari-py#roms for instructions' % (game_name,)) 21 return path 22

Exception: ROM is missing for breakout, see https://github.com/openai/atari-py#roms for instructions

berni-lehner commented 3 years ago

It seems this is a general issue with Colab+gym, I fail to create the pong environment, with the same code that worked flawlessly on Saturday.

dusty-keyboard commented 3 years ago

Found a fix. Go to http://www.atarimania.com/rom_collection_archive_atari_2600_roms.html and download the .rar file with the roms. Extract that .rar file on your local machine. There are 2 zip files in the extracted folder. Then upload those 2 zip files to you colab project.. inside your colab notebook run the following from google.colab import files uploaded = files.upload()

This will give you a button to browse your local machine. Upload those 2 zip files.

Then in you colab notebook run the following !python -m atari_py.import_roms .

Don't forget the . at the end. Then you can run atari gym.

0x15F9 commented 3 years ago

I was also experiencing the same problem and, based on the previous answers, I wrote this short script to be used in colab. I hope someone finds it useful.

! wget http://www.atarimania.com/roms/Roms.rar
! mkdir /content/ROM/
! unrar e /content/Roms.rar /content/ROM/
! python -m atari_py.import_roms /content/ROM/
ageron commented 2 years ago

It's now possible to install Gym along with the ROMs like this:

pip install gym[atari,accept-rom-license]

This installs the autorom package, which provides the AutoROM command, and runs this command with the --accept-rom-license option. AutoROM downloads the ROMs and puts them in the right folders, so everything just works again, but now if Atari decides to sue someone for using their copyrighted ROMs, it will be you, not OpenAI (I'm not a lawyer, though!). 😆

alghenab commented 2 years ago

Just copy and Run.

!wget http://www.atarimania.com/roms/Roms.rar
!unrar x /content/Roms.rar /content
!python -m atari_py.import_roms .
alirezakazemipour commented 2 years ago

@0x15F9 You have no idea how many times I have come back to and used your solution! :heart: Quite a lifesaver! :smile: Thanks a lot.