minerllabs / minerl

MineRL Competition for Sample Efficient Reinforcement Learning - Python Package
http://minerl.io/docs/
Other
711 stars 153 forks source link

Failed to start an environment #621

Open Kamilkime opened 2 years ago

Kamilkime commented 2 years ago

I'm just starting with MineRL - I've downloaded the package, and tried using the example code:

import gym
import minerl
import logging

logging.basicConfig(level=logging.DEBUG)
env = gym.make('MineRLNavigateDense-v0')

obs = env.reset()

However - I'm not able to start the envitonment, I instantly get gradle build errors: https://pastebin.com/TJJfkKnk Java is setup correctly - all environment variables point to JDK 8 folder. I use Python 3.9 on Windows 10: https://pastebin.com/JQKEpWKF I have these packages installed for Python: https://pastebin.com/TFETXbDG

Any ideas what might be wrong here? I work with Minecraft and Java almost every day... But here I'm totally out of ideas :(

Miffyli commented 2 years ago

Hmm that is a new one :o . I tried to dig up if anybody else has had the same issue but could not find related issues. My wild guess is that it is something with using OpenJDK on Windows. On linux this works, but on Windows people (me including) have used the Oracle JDK which works like a charm. Any possibility to try that out?

Also: note that you have to install the package with pip install minerl. Downloading the source from github and running directly won't work, and I recall having issues doing pip install git+[github page] on Windows, too.

Kamilkime commented 2 years ago

Also: note that you have to install the package with pip install minerl. Downloading the source from github and running directly won't work, and I recall having issues doing pip install git+[github page] on Windows, too.

That's how I did it, I followed the documentation for installation and first steps - except for Java installation, that one I already had done.

My wild guess is that it is something with using OpenJDK on Windows. On linux this works, but on Windows people (me including) have used the Oracle JDK which works like a charm. Any possibility to try that out?

After dealing with their stupid downloads and accounts - I've installed Oracle JDK... But it changed nothing. I tried reinstalling minerl - still nothing. And then I tried running that python code from CLI with admin privileges - and it finally worked. Earlier I've installed minerl from admin CLI - maybe that was the problem? Also fun fact - that version of gradle (although working with java 8) does not support lambdas in groovy, my init script broke everything for a second (https://pastebin.com/Yj0HDe34).

And also I have one other question - while running the agent the window looks like this: obraz

Should it be just empty like that? Or is there a way to see what the client is actually doing?

Kamilkime commented 2 years ago

Yup, I've removed minerl installed by admin CLI and I've installed it for my user only - now it works ok with my jupiter notebooks. I guess that would make sense - if I understand correctly, Minecraft files are compiled in the package directory, so if installed by admin in Program Files - they would need an admin to modify those files.

So maybe that would be worth putting in the documentation? Right now there are both command there, but I think that mentioning the admin privileges would also be helpful.

Miffyli commented 2 years ago

Yup, I've removed minerl installed by admin CLI and I've installed it for my user only - now it works ok with my jupiter notebooks. I guess that would make sense - if I understand correctly, Minecraft files are compiled in the package directory, so if installed by admin in Program Files - they would need an admin to modify those files.

Ah, yup, that makes sense to me as well :). Good to hear you managed to fix it!

Should it be just empty like that? Or is there a way to see what the client is actually doing?

In MineRL 0.4.x (current pypi), this is expected behaviour. The window is not updated but Python side will still get the correct images. In MineRL 0.3.7 (installable from pypi) the game window is updated as game progresses.

So maybe that would be worth putting in the documentation? Right now there are both command there, but I think that mentioning the admin privileges would also be helpful.

Yup, sounds like a good tip, especially for Windows users where this can happen more easily (under "Windows Tips"). I would be happy to review and merge a PR on this, if you have time to cook one up (no hard feelings if not) :)

magic-sword commented 2 years ago

Thank you for leaving the QA.

I was also confused by the phenomenon that the game window was not updated from MineRL 0.4.x. However, I understand that this is the expected behavior.

If possible, I would like to fix MineRL 0.4.4 and add an option to update the game window. This is because the game window of the player connected in interactive mode is not updated as follows.

python -m minerl.interactor 6666 image

I think adding a window update option can solve this problem.

I compared the source code and Mission xml of MineRL 0.3.7 and MineRL 0.4.x to find out what changed the window no longer updates. But I couldn't figure out the cause of the change.

What should I fix to get the game window to update? If you know anything, please give me a hint.

Miffyli commented 2 years ago

Hmm the interactive window should update much like normal Minecraft window does (it actually behaves just like playing Minecraft, just at a lower FPS). It might be stuck trying to connect somewhere? For me, starting a code that has make_interactive and then launching interactor with the command you shared works as expected (agent runs in the environment, and I can control the other player via Minecraft window).

In any case, the change that disabled window rendering is here. Not using this code results in bigger problems (the MineRL window keeps being recreated). Imho, current behaviour is more desirable, as the small window should not be used for interaction or rendering in any case (you should use env.render()) :)

magic-sword commented 2 years ago

Thank you for your teaching. Thanks to the detailed tips, I am able to solve the problem!

First, I searched for the possibility of a connection failure, but it didn't seem to be the cause of this problem. The agent's environment log records that the player has successfully connected and joined.

Next, I confirmed the correction of the source code of the MineRL window update in the place where you told me.

As a result, it was found that the game window update was skipped only on the Window OS. After reverting this fix, the MineRL window did continue to regenerate and the player connection failed. I couldn't figure out the cause of the problem that keeps regenerating, so the process of skipping updates is a must.

At the same time, we found that skipping updates to the MineRL window is indiscriminate in the agent and player windows. Since the MineRL window is not regenerated on the player side, it seems that the problem can be solved by updating only the player's MineRL window.

I made the above corrections in the pull request created here. There are still some unstable parts, but I was able to solve the problem for the time being.

If you have time, please review the corrections.