Avalon-Benchmark / avalon

A 3D video game environment and benchmark designed from scratch for reinforcement learning research
https://generallyintelligent.com/avalon/
GNU General Public License v3.0
175 stars 16 forks source link

Error running the quickstart code #21

Closed Minusadd closed 1 year ago

Minusadd commented 1 year ago

I'm trying to run the quickstart code in readme but got the following error (ubuntu 22.04):

Traceback (most recent call last):
  File "/home/haotion/anaconda3/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/haotion/anaconda3/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/haotion/anaconda3/lib/python3.9/multiprocessing/pool.py", line 109, in worker
    initializer(*initargs)
  File "/home/haotion/Downloads/avalon/avalon/datagen/world_creation/world_generator.py", line 460, in disable_sigint
    configure_parent_logging()
  File "/home/haotion/Downloads/avalon/avalon/common/log_utils.py", line 101, in configure_parent_logging
    raise Exception(
Exception: No parent process logging configuration specified. You are likely attempting to call configure_parent_logging without having already called configure_remote_logger or configure_local_logger in a parent process. If this is not a spawned subprocess, you should call one of those two functions rather than calling this function.
Process ForkPoolWorker-364:
Traceback (most recent call last):
  File "/home/haotion/Downloads/avalon/avalon/common/log_utils.py", line 98, in configure_parent_logging
    from computronium.common.log_utils import configure_parent_logging as inner_configure_parent_logging
ModuleNotFoundError: No module named 'computronium'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/haotion/anaconda3/lib/python3.9/multiprocessing/process.py", line 315, in _bootstrap
    self.run()
  File "/home/haotion/anaconda3/lib/python3.9/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/home/haotion/anaconda3/lib/python3.9/multiprocessing/pool.py", line 109, in worker
    initializer(*initargs)
  File "/home/haotion/Downloads/avalon/avalon/datagen/world_creation/world_generator.py", line 460, in disable_sigint
    configure_parent_logging()
  File "/home/haotion/Downloads/avalon/avalon/common/log_utils.py", line 101, in configure_parent_logging
    raise Exception(
Exception: No parent process logging configuration specified. You are likely attempting to call configure_parent_logging without having already called configure_remote_logger or configure_local_logger in a parent process. If this is not a spawned subprocess, you should call one of those two functions rather than calling this function.
Aborted (core dumped)
bai-generally-intelligent commented 1 year ago

Hi, thanks for reporting this. Are you using the latest version of avalon, and are you running it from this github repo or via pip install avalon-rl?

bai-generally-intelligent commented 1 year ago

I am able to reproduce this now, we recently required all scripts to call configure_local_logger before initialization and forgot to update the quickstart code. The correct quickstart code should be the following:

from avalon.agent.godot.godot_gym import GodotEnvironmentParams
from avalon.agent.godot.godot_gym import TrainingProtocolChoice
from avalon.agent.godot.godot_gym import AvalonEnv
from avalon.common.log_utils import configure_local_logger
from avalon.datagen.env_helper import display_video

configure_local_logger()

env_params = GodotEnvironmentParams(
    resolution=256,
    training_protocol=TrainingProtocolChoice.SINGLE_TASK_FIGHT,
    initial_difficulty=1,
)
env = AvalonEnv(env_params)
env.reset()

def random_env_step():
    action = env.action_space.sample()
    obs, reward, done, info = env.step(action)
    if done:
        env.reset()
    return obs

observations = [random_env_step() for _ in range(50)]
display_video(observations, fps=10)

We will push a fix shortly.

Minusadd commented 1 year ago

I am able to reproduce this now, we recently required all scripts to call configure_local_logger before initialization and forgot to update the quickstart code. The correct quickstart code should be the following:

from avalon.agent.godot.godot_gym import GodotEnvironmentParams
from avalon.agent.godot.godot_gym import TrainingProtocolChoice
from avalon.agent.godot.godot_gym import AvalonEnv
from avalon.common.log_utils import configure_local_logger
from avalon.datagen.env_helper import display_video

configure_local_logger()

env_params = GodotEnvironmentParams(
    resolution=256,
    training_protocol=TrainingProtocolChoice.SINGLE_TASK_FIGHT,
    initial_difficulty=1,
)
env = AvalonEnv(env_params)
env.reset()

def random_env_step():
    action = env.action_space.sample()
    obs, reward, done, info = env.step(action)
    if done:
        env.reset()
    return obs

observations = [random_env_step() for _ in range(50)]
display_video(observations, fps=10)

We will push a fix shortly.

I tried this code and got the new error message below:

Worker (PID=106926):  process group: /home/haotion/Downloads/avalon/avalon/datagen/godot/datagen.sh --thread_count=4 -U --input_pipe_path=/tmp/science/tmp/34e956a4-e49b-4451-a070-5d9c54185476/godot.log.actions --output_pipe_path=/tmp/science/tmp/34e956a4-e49b-4451-a070-5d9c54185476/godot.log.observations --resolution=256x256 --cuda-gpu-id=0 /tmp/science/data/96e0e954-f4d6-4779-9eb0-6324171e5091/a4953cce-82ce-4b55-a0e4-4efc2fc242ba/config.json' &>> /tmp/science/tmp/34e956a4-e49b-4451-a070-5d9c54185476/godot.log
Worker (PID=106926):  TO DEBUG RUN: /home/haotion/Downloads/avalon/avalon/datagen/godot/datagen.sh --thread_count=4 -U --input_pipe_path=/tmp/science/data/96e0e954-f4d6-4779-9eb0-6324171e5091/a4953cce-82ce-4b55-a0e4-4efc2fc242ba/actions.out --output_pipe_path=/tmp/debug_output --resolution=256x256 --cuda-gpu-id=0 /tmp/science/data/96e0e954-f4d6-4779-9eb0-6324171e5091/a4953cce-82ce-4b55-a0e4-4efc2fc242ba/config.json
Impossible world was generated, this was try 0... (reason: Could not find start point within mask)
<IPython.core.display.Video object>
bai-generally-intelligent commented 1 year ago

The "Impossible world was generated" happens sometimes when the world generation procedure fails and we have to try again, so getting it occasionally is normal. It's not a problem unless it appears a lot of times.

Minusadd commented 1 year ago

The "Impossible world was generated" happens sometimes when the world generation procedure fails and we have to try again, so getting it occasionally is normal. It's not a problem unless it appears a lot of times.

But I'm getting this error all the time when I try to run the new quickstart code.

bai-generally-intelligent commented 1 year ago

Ah yes, there is a bug in our world generation procedure that it fails the first time it is called. You may ignore it since it appears only once.

(On the other hand, if the world generation gets stuck and generates an invalid world over and over, then that's an actual bug.)