minerllabs/minerl

Issue Running MineRL on WSL2 : Minecraft Window Not Showing Up

coolee218 opened this issue · 4 comments

I am attempting to run the code below on WSL2, Python 3.9, MineRL 1.0.0, with both xvfb and VcXsrv installed. However, the expected window of agent playing MC never shows up, and the process continues indefinitely until I interrupt it with keyboard.

test.py

import gym
import minerl
import logging
logging.basicConfig(level=logging.DEBUG)
env = gym.make('MineRLBasaltFindCave-v0')
obs = env.reset()
print('done reset'+'*'*100)

done = False
while not done:
# Take a random action
action = env.action_space.sample()
# In BASALT environments, sending ESC action will end the episode
# Lets not do that
action["ESC"] = 0
obs, reward, done, _ = env.step(action)
env.render()

Log Output

(vpt) coli@DESKTOP-N38F9B2:~/Video-Pre-Training$ xvfb-run -a python3 test.py
INFO:minerl.env.malmo.instance.359052:Starting Minecraft process: ['/home/coli/.local/lib/python3.9/site-packages/minerl/env/../MCP-Reborn/launchClient.sh', '-port', '12630', '-env', '-runDir', '/home/coli/.local/lib/python3.9/site-packages/minerl/env/../MCP-Reborn/run']
INFO:process_watcher:Launching process watcher daemonizer.
/home/coli/miniconda3/envs/vpt/lib/python3.9/runpy.py:127: RuntimeWarning: 'minerl.utils.process_watcher' found in sys.modules after import of package 'minerl.utils', but prior to execution of 'minerl.utils.process_watcher'; this may result in unpredictable behaviour
warn(RuntimeWarning(msg))
INFO:process_watcher:Process watcher daemonizer launched successfully.
DEBUG:minerl.env.malmo.instance.359052:/home/coli/.local/lib/python3.9/site-packages/minerl/env/../MCP-Reborn
DEBUG:minerl.env.malmo.instance.359052:SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
DEBUG:minerl.env.malmo.instance.359052:SLF4J: Defaulting to no-operation (NOP) logger implementation
DEBUG:minerl.env.malmo.instance.359052:SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
DEBUG:minerl.env.malmo.instance.359052:[02:09:08] [Render thread/INFO]: Environment: authHost='https://authserver.mojang.com', accountsHost='https://api.mojang.com', sessionHost='https://sessionserver.mojang.com', servicesHost='https://api.minecraftservices.com', name='PROD'
DEBUG:minerl.env.malmo.instance.359052:[02:09:09] [Render thread/INFO]: Setting user: Player752
DEBUG:minerl.env.malmo.instance.359052:[02:09:09] [Render thread/INFO]: Backend library: LWJGL version 3.2.2 SNAPSHOT
DEBUG:minerl.env.malmo.instance.359052:libGL error: MESA-LOADER: failed to open swrast: /usr/lib/dri/swrast_dri.so: cannot open shared object file: No such file or directory (search paths /usr/lib/x86_64-linux-gnu/dri:$${ORIGIN}/dri:/usr/lib/dri, suffix _dri)
DEBUG:minerl.env.malmo.instance.359052:libGL error: failed to load driver: swrast
^CTraceback (most recent call last):
File "/home/coli/Video-Pre-Training/test.py", line 6, in
DEBUG:minerl.env.malmo.instance.359052:X connection to :99 broken (explicit kill or server shutdown).
obs = env.reset()
File "/home/coli/.local/lib/python3.9/site-packages/gym/wrappers/time_limit.py", line 26, in reset
return self.env.reset(**kwargs)
File "/home/coli/.local/lib/python3.9/site-packages/gym/wrappers/order_enforcing.py", line 18, in reset
return self.env.reset(**kwargs)
File "/home/coli/.local/lib/python3.9/site-packages/minerl/herobraine/env_specs/basalt_specs.py", line 78, in reset
return self.env.reset()
File "/home/coli/.local/lib/python3.9/site-packages/minerl/herobraine/env_specs/basalt_specs.py", line 57, in reset
return super().reset()
File "/home/coli/.local/lib/python3.9/site-packages/gym/core.py", line 283, in reset
return self.env.reset(**kwargs)
File "/home/coli/.local/lib/python3.9/site-packages/minerl/env/_singleagent.py", line 22, in reset
multi_obs = super().reset()
File "/home/coli/.local/lib/python3.9/site-packages/minerl/env/_multiagent.py", line 436, in reset
self._setup_instances()
File "/home/coli/.local/lib/python3.9/site-packages/minerl/env/_multiagent.py", line 538, in _setup_instances
instance_futures.append(tpe.submit(self._get_new_instance))
DEBUG:minerl.env.malmo.instance.359052:XIO: fatal IO error 22 (Invalid argument) on X server ":99"
File "/home/coli/miniconda3/envs/vpt/lib/python3.9/concurrent/futures/_base.py", line 637, in exit
DEBUG:minerl.env.malmo.instance.359052: after 99 requests (96 known processed) with 12 events remaining.
self.shutdown(wait=True)
File "/home/coli/miniconda3/envs/vpt/lib/python3.9/concurrent/futures/thread.py", line 235, in shutdown
t.join()
File "/home/coli/miniconda3/envs/vpt/lib/python3.9/threading.py", line 1060, in join
self._wait_for_tstate_lock()
File "/home/coli/miniconda3/envs/vpt/lib/python3.9/threading.py", line 1080, in _wait_for_tstate_lock
if lock.acquire(block, timeout):
KeyboardInterrupt

Hey, sorry for the delay on answer, I have been off the grid.

This is expected; there is no visible window from Minecraft, and you are running an infinite loop of things, so this is expected that you see nothing. You would need to render the image from the observation manually or print some other information to see what is happening.

Hey.

@Miffyli I don't think it's expected because the reset call never successfully finished, it's not the loop.

@coolee218 I had exactly the same issue. You have error: failed to load driver: swrast in the output. For me that was the issue and running
export LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libstdc++.so.6
fixed it.
I guess malmo or minerl depends on LWJGL which depends on that driver and is, for some reason, unable to load it, so preloading it fixes the issue.

It worked @Skirlax ! thank you sooooo much! appreciate it!
and thanks for replying me Miffyli

Ah nice catch @Skirlax ! I completely missed there was a print statement :). Thanks for suggesting the fix; never had this happen to me before.

Closing as resolved.