nadavbh12 / Retro-Learning-Environment

The Retro Learning Environment (RLE) -- a learning framework for AI
Other
185 stars 40 forks source link

Illegal instruction (core dumped) when loading the ROM #14

Closed yanpanlau closed 7 years ago

yanpanlau commented 7 years ago

Hi, I got the following error when try to load the ROM, can you please assist? (FYI : can compile the code successfully using the branch 1.0.2)

[inf] "MORTAL KOMBAT" [checksum ok] LoROM, 16Mbits, ROM, NTSC, SRAM:0Kbits, ID:____, CRC32:0BD8EC55
Running ROM file...
Random seed is 123
Illegal instruction (core dumped)

Using gdb debugger I got the following extra information:

R.L.E: Retro Learning Environment (version 1.0.0)
[Based upon the Arcade Learning Environment (A.L.E)]
[Powered by LibRetro]
Use -help for help screen.
[inf] Frontend supports RGB565 - will use that instead of XRGB1555.
Sound buffer size: 128000 (32000 samples)
Core loaded
[inf] No ROM file header found.
Map_LoROMMap
PPU.RenderSub = 0
PPU.FullClipping = 1
Settings.Transparency = 1
Settings.SpeedhackGameID = 0
PPU.SFXSpeedupHack = 0
coldata_update_screen = 1
[inf] "MORTAL KOMBAT" [checksum ok] LoROM, 16Mbits, ROM, NTSC, SRAM:0Kbits, ID:____, CRC32:0BD8EC55
Running ROM file...
Random seed is 123

Program received signal SIGILL, Illegal instruction.
core_audio_sample_batch (data=0x7fffdcf0f9b0 <S9xAudioCallback.audio_buf>, frames=511)
    at /home/ben/deep_q_rl/build/RLE/src/environment/RetroAgent.cpp:316
316 /home/ben/deep_q_rl/build/RLE/src/environment/RetroAgent.cpp: No such file or directory.
nadavbh12 commented 7 years ago

Are you able to reproduce this on 1.1.0?

yanpanlau commented 7 years ago

Yes. I just re-install it via the following scripts:

git clone --branch 1.1.0 https://github.com/nadavbh12/Retro-Learning-Environment.git
cd Retro-Learning-Environment/
mkdir build && cd build
cmake -DUSE_SDL=ON -DBUILD_EXAMPLES=ON ..
make -j 4
cd ..
pip install .
nadavbh12 commented 7 years ago

What's your setup? Could you perhaps do a binary search and find the faulty commit causing the issue?

yanpanlau commented 7 years ago

I am running Ubuntu 14.04 and compile under gcc 4.9

In order to test the setup, I also installed ZSNES and I can run the ROM successfully.

Can you advice how to do a binary search and how to find the faulty commit?

steetfigher

nadavbh12 commented 7 years ago

Since you got it to work under 1.0.2 I conclude there must have been a subsequant commit which broke it. You can run git log to view the latest commits. Run git checkout <commit id> to change to a previous commit. You can go back one by one and see which is the one the crashes. Or you can binary search through them to find it faster.

yanpanlau commented 7 years ago

I did few more test

1) Neither RLE 1.0.2 or 1.1.0 works 2) The ubuntu emulator ZSENS works (works) 3) The another emulator retroarch works (works) 4) The ALE environments https://github.com/mgbellemare/Arcade-Learning-Environment.git (works) 5) From the debugger info, it seems it is related to the audio in RetroAgent.cpp (line 316) static size_t core_audio_sample_batch(const int16_t *data, size_t frames) {}

I have re-install it from fresh but it seems cannot solve the problem. Attached is my compile log file hope it can help you to find out the reason?

compile_log.txt

nadavbh12 commented 7 years ago

I see that you've named your ROM test.sfc.

RLE requires that the ROM name be identical to the ROM name as defined in the .h file (an error message was added catching this in a later RLE version). So for mortal kombat that would be mortal_kombat.sfc .

Please try re-running this in version 1.0.2. It would also be better to run the sharedlibraryinterface example so we know the problem is within RLE or the emulator rather than with the Python interface.

Regarding 3. - which emulator did you use for SNES? If the above doesn't work, try using it with SNES9x2010.

yanpanlau commented 7 years ago

Thanks for quick reply, here is how I run

./python_example.py Mortal_Kombat.sfc ../../snes9x2010/snes9x2010_libretro.so

I am using Ubuntu 14.04 in the previous setup


I just did a new test, I use another computer and re-format and install Ubuntu 16.04, and it works with RLE 1.0.2, but it won't work for RLE 1.1.0 or RLE 1.1.1

The error was like this (during pip install)

Processing /home/dickson/RLE
Installing collected packages: rle-python-interface
  Running setup.py install for rle-python-interface ... error
    Complete output from command /usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-l48SiO-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-qNFFnm-record/install-record.txt --single-version-externally-managed --compile:
    running install
    running build
    cmake .. -DBUILD_EXAMPLES=OFF -DBUILD_PYTHON=ON
    CMake Error: The current CMakeCache.txt directory /tmp/pip-l48SiO-build/build/CMakeCache.txt is different than the directory /home/dickson/RLE/build where CMakeCache.txt was created. This may result in binaries being created in the wrong place. If you are not sure, reedit the CMakeCache.txt
    CMake Error: The source "/tmp/pip-l48SiO-build/CMakeLists.txt" does not match the source "/home/dickson/RLE/CMakeLists.txt" used to generate cache.  Re-run cmake with a different source directory.
    Error while running cmake

    ----------------------------------------
Command "/usr/bin/python -u -c "import setuptools, tokenize;__file__='/tmp/pip-l48SiO-build/setup.py';f=getattr(tokenize, 'open', open)(__file__);code=f.read().replace('\r\n', '\n');f.close();exec(compile(code, __file__, 'exec'))" install --record /tmp/pip-qNFFnm-record/install-record.txt --single-version-externally-managed --compile" failed with error code 255 in /tmp/pip-l48SiO-build/
nadavbh12 commented 7 years ago

In the newest version (not sure if 1.1.0 or 1.1.1) you no longer need to run the build command (cmake + make), setup.py does that for you. Remove CMakeCache.txt and then run pip install . again.

yanpanlau commented 7 years ago

We are getting close. OK. On Ubuntu 16.04 + RLE 1.1.1 + Street Fighter II + USE_SDL == FALSE, it works!

./python_example.py Street_Fighter_II.sfc snes

But if I turn on the USE_SDL (to see the sound and graphics, I have the following error)

[Based upon the Arcade Learning Environment (A.L.E)]
[Powered by LibRetro]
Use -help for help screen.
terminate called after throwing an instance of 'std::runtime_error'
  what():  The key sound you are trying to set does not exist.

Aborted (core dumped)

(I can see the video under RLE 1.0.2 with USE_SDL == True)

nadavbh12 commented 7 years ago

Well that seems to be a bug I found a few days back and forgot to push the fix. Sorry about that.

yanpanlau commented 7 years ago

Hum...I tried the 7c6e062...but error remains the same

git clone https://github.com/nadavbh12/Retro-Learning-Environment.git
cd Retro-Learning-Environment/
sudo pip install --upgrade --no-deps --force-reinstall .
cd ~/Retro-Learning-Environment/doc/examples
./python_example.py Street_Fighter_II.sfc snes
R.L.E: Retro Learning Environment (version 1.1.1)
[Based upon the Arcade Learning Environment (A.L.E)]
[Powered by LibRetro]
Use -help for help screen.
terminate called after throwing an instance of 'std::runtime_error'
  what():  The key sound you are trying to set does not exist.

Aborted (core dumped)
nadavbh12 commented 7 years ago

You're correct. I've updates the shared_library example but not the python example. Please try now after the newer fix.

yanpanlau commented 7 years ago

I just tried the newer fix.

However, there is no video screen come out....

We are 99.9% there.....

nadavbh12 commented 7 years ago

Usually when using the Python interface the SDL screen isn't used. If you want to use it you can edit setup.py and add `-DUSE_SDL=ON' to the Cmake args.

yanpanlau commented 7 years ago

Awesome! Finally it works!

Just curious, how to turn the sound on? It will be REALLY cool to have both screen and sound on at the same time

nadavbh12 commented 7 years ago

Glad to hear it finally worked out. We haven't implemented the sound yet, so I'm afraid it's not possible.

nadavbh12 commented 7 years ago

I just gave it another look and it turned out to be rather easy to implement. So you can now enable sound by settings 'sound' to true.

yanpanlau commented 7 years ago

Awesome. I just test. It works perfectly! That's the best AI platform! wonderful work.