awarelab / continual_world

79 stars 16 forks source link

Issue with env.step #6

Open sayantanauddy opened 1 year ago

sayantanauddy commented 1 year ago

First of all, thanks for making this repository available to everyone!

I am facing a problem related to running continual world and maybe you can help. I followed the docker instructions in the readme and set up and built the container. Inside the container, when I run

python3 run_single.py --seed 0 --steps 2e3 --log_every 250 --task hammer-v1 --logger_output tsv tensorboard

I get the following error, which complains about the number of arguments returned by env.step():

/usr/local/lib/python3.6/dist-packages/gym/spaces/box.py:127: UserWarning: WARN: Box bound precision lowered by casting to float32
  logger.warn(f"Box bound precision lowered by casting to {self.dtype}")
Traceback (most recent call last):
  File "run_single.py", line 62, in <module>
    main(logger, **args)
  File "run_single.py", line 53, in main
    sac.run()
  File "/continualworld/continualworld/sac/sac.py", line 560, in run
    next_obs, reward, done, info = self.env.step(action)
  File "/continualworld/continualworld/utils/wrappers.py", line 19, in step
    obs, reward, done, info = self.env.step(action)
  File "/usr/local/lib/python3.6/dist-packages/gym/wrappers/time_limit.py", line 50, in step
    observation, reward, terminated, truncated, info = self.env.step(action)
ValueError: not enough values to unpack (expected 5, got 4)

I edited the file /usr/local/lib/python3.6/dist-packages/gym/wrappers/time_limit.py and removed the truncated return value and after this the script run_single.py runs fine.

    def step(self, action):
        """Steps through the environment and if the number of steps elapsed exceeds ``max_episode_steps`` then truncate.

        Args:
            action: The environment step action

        Returns:
            The environment step ``(observation, reward, terminated, truncated, info)`` with `truncated=True`
            if the number of steps elapsed >= max episode steps

        """
        observation, reward, terminated, info = self.env.step(action)
        #observation, reward, terminated, truncated, info = self.env.step(action)
        self._elapsed_steps += 1

        if self._elapsed_steps >= self._max_episode_steps:
            truncated = True

        # return observation, reward, terminated, truncated, info
        return observation, reward, terminated, info

I am not sure if this is an issue with a version of gym or something else. I am pretty sure I followed the exact steps described in the readme. Perhaps you can suggest a remedy so that I can run the example code without any hacks like changing the internals of llibrary functions? Thanks in advance.

piotrmilos commented 1 year ago

Thank your for your email. The error is due to change of gym api. The simplest solution is downgrading.

Let us know if this help, best write directly on our emails: @. @.> or Maciej Wolczyk @.***> (who was one of the main developers behind the code).

Best, Piotr

Piotr Miłoś Associate Professor Polish Academy of Sciences www.mimuw.edu.pl/~pmilos

On 3 Jan 2023, at 15:01, Sayantan Auddy @.***> wrote:

First of all, thanks for making this repository available to everyone!

I am facing a problem related to running continual world and maybe you can help. I followed the docker instructions in the readme and set up and built the container. Inside the container, when I run

python3 run_single.py --seed 0 --steps 2e3 --log_every 250 --task hammer-v1 --logger_output tsv tensorboard I get the following error, which complains about the number of arguments returned by env.step():

/usr/local/lib/python3.6/dist-packages/gym/spaces/box.py:127: UserWarning: WARN: Box bound precision lowered by casting to float32 logger.warn(f"Box bound precision lowered by casting to {self.dtype}") Traceback (most recent call last): File "run_single.py", line 62, in main(logger, **args) File "run_single.py", line 53, in main sac.run() File "/continualworld/continualworld/sac/sac.py", line 560, in run next_obs, reward, done, info = self.env.step(action) File "/continualworld/continualworld/utils/wrappers.py", line 19, in step obs, reward, done, info = self.env.step(action) File "/usr/local/lib/python3.6/dist-packages/gym/wrappers/time_limit.py", line 50, in step observation, reward, terminated, truncated, info = self.env.step(action) ValueError: not enough values to unpack (expected 5, got 4) I edited the file /usr/local/lib/python3.6/dist-packages/gym/wrappers/time_limit.py and removed the truncated return value and after this the script run_single.py runs fine.

def step(self, action):
    """Steps through the environment and if the number of steps elapsed exceeds ``max_episode_steps`` then truncate.

    Args:
        action: The environment step action

    Returns:
        The environment step ``(observation, reward, terminated, truncated, info)`` with `truncated=True`
        if the number of steps elapsed >= max episode steps

    """
    observation, reward, terminated, info = self.env.step(action)
    #observation, reward, terminated, truncated, info = self.env.step(action)
    self._elapsed_steps += 1

    if self._elapsed_steps >= self._max_episode_steps:
        truncated = True

    # return observation, reward, terminated, truncated, info
    return observation, reward, terminated, info

I am not sure if this is an issue with a version of gym or something else. I am pretty sure I followed the exact steps described in the readme. Perhaps you can suggest a remedy so that I can run the example code without any hacks like changing the internals of llibrary functions? Thanks in advance.

— Reply to this email directly, view it on GitHub https://github.com/awarelab/continual_world/issues/6, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEX3DMOCVLT6EHFD4MWQGJ3WQQWLZANCNFSM6AAAAAATPXANUU. You are receiving this because you are subscribed to this thread.

sayantanauddy commented 1 year ago

@piotrmilos Thanks for the quick response.

I can confirm that this issue is resolved by downgrading to gym 0.25.2, since version 0.26.0 broke backward compatibility (more details here).

Please consider adding the specific gym version as a dependency. Thanks agian.

piotrmilos commented 1 year ago

Yes, I am sorry for that. We plan to refactor the code, but as usual, there are always more urgent things to do

Piotr Miłoś @.***

On 3 Jan 2023, at 17:38, Sayantan Auddy @.***> wrote:

@piotrmilos https://github.com/piotrmilos Thanks for the quick response.

I can confirm that this issue is resolved by downgrading to gym 0.25.2, since version 0.26.0 broke backward compatibility (more details here https://github.com/openai/gym/releases/tag/0.26.0).

Please consider adding the specific gym version as a dependency. Thanks agian.

— Reply to this email directly, view it on GitHub https://github.com/awarelab/continual_world/issues/6#issuecomment-1369983016, or unsubscribe https://github.com/notifications/unsubscribe-auth/AEX3DMOKAHIVVYYUZVQ44TDWQRI2FANCNFSM6AAAAAATPXANUU. You are receiving this because you were mentioned.