Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some installation bugs and installation on windows #39

Open
YCHuang2112 opened this issue Sep 5, 2022 · 1 comment
Open

Some installation bugs and installation on windows #39

YCHuang2112 opened this issue Sep 5, 2022 · 1 comment

Comments

@YCHuang2112
Copy link

YCHuang2112 commented Sep 5, 2022

Before running python Minedojo code, go xxx/minedojo/sim/Malmo/Minecraft/ where your python put minedojo package and execute ./launchClient.sh (for linux/unix) or .\launchClient (for windows, there's a launchClient.bat file) and make sure it can run normally before you start with Minedojo.

It will be good to not directly delete your files, instead just save it somewhere or change their names until you're really sure those files are not necessary any more.

install old java: java8
(on ubuntu) "sudo apt-get install openjdk-8-jdk", then using "sudo update-alternatives --config java" to set system using java8

For Deprecated Gradle feature --> Go to Malmo project download latest prebuild version https://github.com/Microsoft/malmo/releases. Then find and replace the Malmo directory in your python package directory @ xxx/minedojo/sim/Malmo on your computer. (Reminder directory shall keep the same name "Malmo") (Not so sure whether this will solve your problem but it works for me for I've tried and made couples of changes and not so certain about which part is the key.)

For "OpenGL: ERROR RuntimeException: No OpenGL context found in the current thread." (X Error & bad value) --> make sure you run sudo apt update && sudo apt upgrade and replace Malmo directory with a new clean one before you compile the minecraft java program as the same problem has been described in https://stackoverflow.com/questions/28867285/lwjgl-reports-that-opengl-is-not-supported-on-a-modern-nvidia-card. This works for me.

As running Minedojo, when you first call env = minedojo.make(...), on windows it will held on at xxx/gym/spaces/dict.py where inside def seed() it calls np.random.state.choice(
np.iinfo(int).max,
size=len(self.spaces),
replace=False, # unique subseed for each subspace
).
As stated in https://numpy.org/doc/stable/reference/random/generated/numpy.random.RandomState.choice.html, if the first argument is an int number, the random sample is generated as if it were np.arange(a) so this generates a MAX_INT size of
array which makes it currently run very slow on Windows. Considering replacing it with : subseeds = np.random.randint(0,np.iinfo(int).max, size=len(self.spaces)).

For Windows to let minedojo run xxx/minedojo/sim/Malmo/Minecraft/launchClient.bat (Minecraft bat execution program), changing launch_script = "launchClient.sh" in file xxx/minedojo/sim/bridge/mc_instance/instance.py -> def _launch_minecraft(...): to launch_script = "launchClient.bat".

However, currently for windows @ xxx/minedojo/sim/bridge/utils/watchdog.py watchdog program uses Daemonize (from daemoniker import Daemonizer) which has some compatibility issue on windows as described in Muterra/py_daemoniker#8 and in pip daemoniker website introduction https://daemoniker.readthedocs.io/en/latest/, signal.signal has a very large difference on Windows and on Linux system.
As it was marked on xxx/minedojo/sim/bridge/mc_instance/instance.py as
if os.name == "nt":
raise ValueError("TODO")
This project was not yet for pure Windows users.

To circumvent this, as for me using Windows 11, one can choose using WSL2. https://pureinfotech.com/install-windows-subsystem-linux-2-windows-10/
After installation, if you are Windows 11, then one must notice that installing and activate X-server (like startxfce4) may cause conflict for wsl on windows 11 is made support vgpu which defaultly run a Xserver in the background. If you encounter message like "Xserver in already running" but without exiting right away, then it will be the case. For windows 11 users, one must reference this Microsoft official github issue page: https://github.com/microsoft/wslg/wiki/Diagnosing-%22cannot-open-display%22-type-issues-with-WSLg.

After two days, it finally works for me. ......
It seems like there're still couple of works remained here.
As for env.action_space, I haven't find env.action_space.high, env.action_space.low.
But one can reference from the comment parts in wrapper files.
Like in xxx/minedojo/sim/wrappers/ar_nn/nn_action_space_wrapper.py, it gives
self.action_space = spaces.MultiDiscrete(
[
3, # forward and back, 0: noop, 1: forward, 2: back
3, # 0: noop, 1: left, 2: right
4, # 0: noop, 1: jump, 2: sneak, 3: sprint
n_pitch_bins, # camera pitch, 0: -180, n_pitch_bins - 1: +180
n_yaw_bins, # camera yaw, 0: -180, n_yaw_bins - 1: +180,
8, # functional actions, 0: no_op, 1: use, 2: drop, 3: attack 4: craft 5: equip 6: place 7: destroy
len(MC.ALL_CRAFT_SMELT_ITEMS), # arg for "craft"
MC.N_INV_SLOTS, # arg for "equip", "place", and "destroy"
]
So action_space[4] --> means turning left/right. Comment here shows 0: -180, n_yaw_bins - 1: +180, which means [12,13,...,24(=0),1,2,...,11] corresponding to turning clockwisely [0,15,30,...330,345] degrees.

@yunfanjiang
Copy link
Member

Hey @YCHuang2112, thank you for sharing these experiences. Would you mind open a PR to incorporate these guides? We would like to review and merge it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants