minerllabs / minerl

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

MineRL environment not loading, possible error with initializing GLFW #654

Closed pnlong closed 2 years ago

pnlong commented 2 years ago

So I have successfully installed the minerl package into my anaconda environment. I am running Python 3.9.12. I am working on a remote server where I will then use X11 forwarding to display anything the minerl package needs to display. The following code runs successfully:

Python 3.9.12 (main, Jun  1 2022, 11:38:51) 
[GCC 7.5.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import gym, minerl, logging
>>> logging.basicConfig(level=logging.DEBUG)
>>> env = gym.make('MineRLBasaltFindCave-v0')

All good, right? However, when I then run >>> obs = env.reset(), I am first greeted with this warning:

/data/homezvol2/pnlong/.conda/envs/minerl/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))

Some research as well as discussion on the minerl discord server has told me that this warning is normal, and even pops up on successful minerl runs. Ok. However, after this warning, what is not normal is that I get the following error, and I cannot get minerl to work.

INFO:process_watcher:Process watcher daemonizer launched successfully.
DEBUG:minerl.env.malmo.instance.b69757:/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/env/../MCP-Reborn
DEBUG:minerl.env.malmo.instance.b69757:SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
DEBUG:minerl.env.malmo.instance.b69757:SLF4J: Defaulting to no-operation (NOP) logger implementation
DEBUG:minerl.env.malmo.instance.b69757:SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
DEBUG:minerl.env.malmo.instance.b69757:[18:19:51] [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'
ERROR:minerl.env.malmo.instance.b69757:[18:19:53] [Render thread/ERROR]: Failed to verify authentication!
DEBUG:minerl.env.malmo.instance.b69757:[18:19:53] [Render thread/INFO]: Setting user: Player979
DEBUG:minerl.env.malmo.instance.b69757:[18:19:53] [Render thread/INFO]: Backend library: LWJGL version 3.2.1 SNAPSHOT
DEBUG:minerl.env.malmo.instance.b69757:---- Minecraft Crash Report ----
DEBUG:minerl.env.malmo.instance.b69757:// Don't do that.
DEBUG:minerl.env.malmo.instance.b69757:
DEBUG:minerl.env.malmo.instance.b69757:Time: 7/22/22 6:19 PM
DEBUG:minerl.env.malmo.instance.b69757:Description: Initializing game
DEBUG:minerl.env.malmo.instance.b69757:
ERROR:minerl.env.malmo.instance.b69757:java.lang.IllegalStateException: Failed to initialize GLFW, errors: GLFW error during init: [0x10008]140586126389024
DEBUG:minerl.env.malmo.instance.b69757: at com.mojang.blaze3d.platform.GLX._initGlfw(GLX.java:80)
DEBUG:minerl.env.malmo.instance.b69757: at com.mojang.blaze3d.systems.RenderSystem.initBackendSystem(RenderSystem.java:586)
DEBUG:minerl.env.malmo.instance.b69757: at net.minecraft.client.Minecraft.<init>(Minecraft.java:406)
DEBUG:minerl.env.malmo.instance.b69757: at net.minecraft.client.main.Main.main(Main.java:154)
DEBUG:minerl.env.malmo.instance.b69757:
DEBUG:minerl.env.malmo.instance.b69757:
DEBUG:minerl.env.malmo.instance.b69757:A detailed walkthrough of the error, its code path and all known details is as follows:
DEBUG:minerl.env.malmo.instance.b69757:---------------------------------------------------------------------------------------
DEBUG:minerl.env.malmo.instance.b69757:
DEBUG:minerl.env.malmo.instance.b69757:-- Head --
DEBUG:minerl.env.malmo.instance.b69757:Thread: Render thread
DEBUG:minerl.env.malmo.instance.b69757:Stacktrace:
DEBUG:minerl.env.malmo.instance.b69757: at com.mojang.blaze3d.platform.GLX._initGlfw(GLX.java:80)
DEBUG:minerl.env.malmo.instance.b69757: at com.mojang.blaze3d.systems.RenderSystem.initBackendSystem(RenderSystem.java:586)
DEBUG:minerl.env.malmo.instance.b69757: at net.minecraft.client.Minecraft.<init>(Minecraft.java:406)
DEBUG:minerl.env.malmo.instance.b69757:
DEBUG:minerl.env.malmo.instance.b69757:-- Initialization --
DEBUG:minerl.env.malmo.instance.b69757:Details:
DEBUG:minerl.env.malmo.instance.b69757:Stacktrace:
DEBUG:minerl.env.malmo.instance.b69757: at net.minecraft.client.main.Main.main(Main.java:154)
DEBUG:minerl.env.malmo.instance.b69757:
DEBUG:minerl.env.malmo.instance.b69757:-- System Details --
DEBUG:minerl.env.malmo.instance.b69757:Details:
DEBUG:minerl.env.malmo.instance.b69757: Minecraft Version: 1.16.5
DEBUG:minerl.env.malmo.instance.b69757: Minecraft Version ID: 1.16.5
DEBUG:minerl.env.malmo.instance.b69757: Operating System: Linux (amd64) version 3.10.0-1160.53.1.el7.x86_64
DEBUG:minerl.env.malmo.instance.b69757: Java Version: 1.8.0_332, Azul Systems, Inc.
DEBUG:minerl.env.malmo.instance.b69757: Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Azul Systems, Inc.
DEBUG:minerl.env.malmo.instance.b69757: Memory: 61228952 bytes (58 MB) / 242663424 bytes (231 MB) up to 4151836672 bytes (3959 MB)
DEBUG:minerl.env.malmo.instance.b69757: CPUs: 1
DEBUG:minerl.env.malmo.instance.b69757: JVM Flags: 1 total; -Xmx4G
DEBUG:minerl.env.malmo.instance.b69757: Launched Version: ~~NULL~~
DEBUG:minerl.env.malmo.instance.b69757: Backend library: LWJGL version 3.2.1 SNAPSHOT
DEBUG:minerl.env.malmo.instance.b69757: Backend API: NO CONTEXT
DEBUG:minerl.env.malmo.instance.b69757: GL Caps: 
DEBUG:minerl.env.malmo.instance.b69757: Using VBOs: Yes
DEBUG:minerl.env.malmo.instance.b69757: Is Modded: Very likely; Jar signature invalidated
DEBUG:minerl.env.malmo.instance.b69757: Type: Client (map_client.txt)
DEBUG:minerl.env.malmo.instance.b69757: CPU: <unknown>
DEBUG:minerl.env.malmo.instance.b69757:#@!@# Game crashed! Crash report saved to: #@!@# /data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/MCP-Reborn/./crash-reports/crash-2022-07-22_18.19.53-client.txt
ERROR:minerl.env.malmo.instance.b69757:/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/env/../MCP-Reborn
ERROR:minerl.env.malmo.instance.b69757:SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
ERROR:minerl.env.malmo.instance.b69757:SLF4J: Defaulting to no-operation (NOP) logger implementation
ERROR:minerl.env.malmo.instance.b69757:SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
ERROR:minerl.env.malmo.instance.b69757:[18:19:51] [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'
ERROR:minerl.env.malmo.instance.b69757:[18:19:53] [Render thread/ERROR]: Failed to verify authentication!
ERROR:minerl.env.malmo.instance.b69757:[18:19:53] [Render thread/INFO]: Setting user: Player979
ERROR:minerl.env.malmo.instance.b69757:[18:19:53] [Render thread/INFO]: Backend library: LWJGL version 3.2.1 SNAPSHOT
ERROR:minerl.env.malmo.instance.b69757:---- Minecraft Crash Report ----
ERROR:minerl.env.malmo.instance.b69757:// Don't do that.
ERROR:minerl.env.malmo.instance.b69757:
ERROR:minerl.env.malmo.instance.b69757:Time: 7/22/22 6:19 PM
ERROR:minerl.env.malmo.instance.b69757:Description: Initializing game
ERROR:minerl.env.malmo.instance.b69757:
ERROR:minerl.env.malmo.instance.b69757:java.lang.IllegalStateException: Failed to initialize GLFW, errors: GLFW error during init: [0x10008]140586126389024
ERROR:minerl.env.malmo.instance.b69757: at com.mojang.blaze3d.platform.GLX._initGlfw(GLX.java:80)
ERROR:minerl.env.malmo.instance.b69757: at com.mojang.blaze3d.systems.RenderSystem.initBackendSystem(RenderSystem.java:586)
ERROR:minerl.env.malmo.instance.b69757: at net.minecraft.client.Minecraft.<init>(Minecraft.java:406)
ERROR:minerl.env.malmo.instance.b69757: at net.minecraft.client.main.Main.main(Main.java:154)
ERROR:minerl.env.malmo.instance.b69757:
ERROR:minerl.env.malmo.instance.b69757:
ERROR:minerl.env.malmo.instance.b69757:A detailed walkthrough of the error, its code path and all known details is as follows:
ERROR:minerl.env.malmo.instance.b69757:---------------------------------------------------------------------------------------
ERROR:minerl.env.malmo.instance.b69757:
ERROR:minerl.env.malmo.instance.b69757:-- Head --
ERROR:minerl.env.malmo.instance.b69757:Thread: Render thread
ERROR:minerl.env.malmo.instance.b69757:Stacktrace:
ERROR:minerl.env.malmo.instance.b69757: at com.mojang.blaze3d.platform.GLX._initGlfw(GLX.java:80)
ERROR:minerl.env.malmo.instance.b69757: at com.mojang.blaze3d.systems.RenderSystem.initBackendSystem(RenderSystem.java:586)
ERROR:minerl.env.malmo.instance.b69757: at net.minecraft.client.Minecraft.<init>(Minecraft.java:406)
ERROR:minerl.env.malmo.instance.b69757:
ERROR:minerl.env.malmo.instance.b69757:-- Initialization --
ERROR:minerl.env.malmo.instance.b69757:Details:
ERROR:minerl.env.malmo.instance.b69757:Stacktrace:
ERROR:minerl.env.malmo.instance.b69757: at net.minecraft.client.main.Main.main(Main.java:154)
ERROR:minerl.env.malmo.instance.b69757:
ERROR:minerl.env.malmo.instance.b69757:-- System Details --
ERROR:minerl.env.malmo.instance.b69757:Details:
ERROR:minerl.env.malmo.instance.b69757: Minecraft Version: 1.16.5
ERROR:minerl.env.malmo.instance.b69757: Minecraft Version ID: 1.16.5
ERROR:minerl.env.malmo.instance.b69757: Operating System: Linux (amd64) version 3.10.0-1160.53.1.el7.x86_64
ERROR:minerl.env.malmo.instance.b69757: Java Version: 1.8.0_332, Azul Systems, Inc.
ERROR:minerl.env.malmo.instance.b69757: Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Azul Systems, Inc.
ERROR:minerl.env.malmo.instance.b69757: Memory: 61228952 bytes (58 MB) / 242663424 bytes (231 MB) up to 4151836672 bytes (3959 MB)
ERROR:minerl.env.malmo.instance.b69757: CPUs: 1
ERROR:minerl.env.malmo.instance.b69757: JVM Flags: 1 total; -Xmx4G
ERROR:minerl.env.malmo.instance.b69757: Launched Version: ~~NULL~~
ERROR:minerl.env.malmo.instance.b69757: Backend library: LWJGL version 3.2.1 SNAPSHOT
ERROR:minerl.env.malmo.instance.b69757: Backend API: NO CONTEXT
ERROR:minerl.env.malmo.instance.b69757: GL Caps: 
ERROR:minerl.env.malmo.instance.b69757: Using VBOs: Yes
ERROR:minerl.env.malmo.instance.b69757: Is Modded: Very likely; Jar signature invalidated
ERROR:minerl.env.malmo.instance.b69757: Type: Client (map_client.txt)
ERROR:minerl.env.malmo.instance.b69757: CPU: <unknown>
ERROR:minerl.env.malmo.instance.b69757:#@!@# Game crashed! Crash report saved to: #@!@# /data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/MCP-Reborn/./crash-reports/crash-2022-07-22_18.19.53-client.txt
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/gym/wrappers/time_limit.py", line 27, in reset
    return self.env.reset(**kwargs)
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/herobraine/env_specs/basalt_specs.py", line 77, in reset
    return self.env.reset()
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/herobraine/env_specs/basalt_specs.py", line 56, in reset
    return super().reset()
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/gym/core.py", line 251, in reset
    return self.env.reset(**kwargs)
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/env/_singleagent.py", line 22, in reset
    multi_obs = super().reset()
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/env/_multiagent.py", line 436, in reset
    self._setup_instances()
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/env/_multiagent.py", line 539, in _setup_instances
    self.instances.extend([f.result() for f in instance_futures])
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/env/_multiagent.py", line 539, in <listcomp>
    self.instances.extend([f.result() for f in instance_futures])
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/concurrent/futures/_base.py", line 439, in result
    return self.__get_result()
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/concurrent/futures/_base.py", line 391, in __get_result
    raise self._exception
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/env/_multiagent.py", line 805, in _get_new_instance
    instance.launch(replaceable=self._is_fault_tolerant)
  File "/data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/env/malmo.py", line 427, in launch
    raise EOFError(
EOFError: /data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/env/../MCP-Reborn
SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder".
SLF4J: Defaulting to no-operation (NOP) logger implementation
SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details.
[18:19:51] [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'
[18:19:53] [Render thread/ERROR]: Failed to verify authentication!
[18:19:53] [Render thread/INFO]: Setting user: Player979
[18:19:53] [Render thread/INFO]: Backend library: LWJGL version 3.2.1 SNAPSHOT
---- Minecraft Crash Report ----
// Don't do that.

Time: 7/22/22 6:19 PM
Description: Initializing game

java.lang.IllegalStateException: Failed to initialize GLFW, errors: GLFW error during init: [0x10008]140586126389024
    at com.mojang.blaze3d.platform.GLX._initGlfw(GLX.java:80)
    at com.mojang.blaze3d.systems.RenderSystem.initBackendSystem(RenderSystem.java:586)
    at net.minecraft.client.Minecraft.<init>(Minecraft.java:406)
    at net.minecraft.client.main.Main.main(Main.java:154)

A detailed walkthrough of the error, its code path and all known details is as follows:
---------------------------------------------------------------------------------------

-- Head --
Thread: Render thread
Stacktrace:
    at com.mojang.blaze3d.platform.GLX._initGlfw(GLX.java:80)
    at com.mojang.blaze3d.systems.RenderSystem.initBackendSystem(RenderSystem.java:586)
    at net.minecraft.client.Minecraft.<init>(Minecraft.java:406)

-- Initialization --
Details:
Stacktrace:
    at net.minecraft.client.main.Main.main(Main.java:154)

-- System Details --
Details:
    Minecraft Version: 1.16.5
    Minecraft Version ID: 1.16.5
    Operating System: Linux (amd64) version 3.10.0-1160.53.1.el7.x86_64
    Java Version: 1.8.0_332, Azul Systems, Inc.
    Java VM Version: OpenJDK 64-Bit Server VM (mixed mode), Azul Systems, Inc.
    Memory: 61228952 bytes (58 MB) / 242663424 bytes (231 MB) up to 4151836672 bytes (3959 MB)
    CPUs: 1
    JVM Flags: 1 total; -Xmx4G
    Launched Version: ~~NULL~~
    Backend library: LWJGL version 3.2.1 SNAPSHOT
    Backend API: NO CONTEXT
    GL Caps: 
    Using VBOs: Yes
    Is Modded: Very likely; Jar signature invalidated
    Type: Client (map_client.txt)
    CPU: <unknown>
#@!@# Game crashed! Crash report saved to: #@!@# /data/homezvol2/pnlong/.conda/envs/minerl/lib/python3.9/site-packages/minerl/MCP-Reborn/./crash-reports/crash-2022-07-22_18.19.53-client.txt

Minecraft process finished unexpectedly. There was an error with Malmo.

I want to say that the issue root of the issue is here:

java.lang.IllegalStateException: Failed to initialize GLFW, errors: GLFW error during init: [0x10008]140586126389024
    at com.mojang.blaze3d.platform.GLX._initGlfw(GLX.java:80)
    at com.mojang.blaze3d.systems.RenderSystem.initBackendSystem(RenderSystem.java:586)
    at net.minecraft.client.Minecraft.<init>(Minecraft.java:406)
    at net.minecraft.client.main.Main.main(Main.java:154)

The issue is similar to the one mentioned here, but it is not the same. I have looked into "GLFW" errors and come across this, which suggests installing a new version of LWJGL (Lightweight Java Game Library). I don't know how to do this though or where I'd install it. But this could very well be a red herring as well.

This is the info about my java version:

openjdk version "1.8.0_332"
OpenJDK Runtime Environment (Zulu 8.62.0.19-CA-linux64) (build 1.8.0_332-b09)
OpenJDK 64-Bit Server VM (Zulu 8.62.0.19-CA-linux64) (build 25.332-b09, mixed mode)

Has anyone encountered this issue? If so, did you find a work-around? Thanks in advance.

Miffyli commented 2 years ago

Hey. To run on headless servers, our go-to recommendation is to use Xvfb to create a virtual display buffer. On Debian you can install it with sudo apt install xvfb, and then run your code with xvfb-run -a python your_script.py. That should fix the issue :)

pnlong commented 2 years ago

Thank you @Miffyli.

While I continue to get the following warning --

/data/homezvol2/pnlong/.conda/envs/minerl/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))

--- my program now runs without error.