sail-sg / envpool

C++-based high-performance parallel environment execution engine (vectorized env) for general RL environments.
https://envpool.readthedocs.io
Apache License 2.0
1.09k stars 100 forks source link

[All parallel environments have env-id 0 ] #312

Open RajGhugare19 opened 2 months ago

RajGhugare19 commented 2 months ago

Describe the bug

A clear and concise description of what the bug is.

To Reproduce

after using fresh anaconda env / venv installing a fresh envpool using pip install envpool , and running :

import gym
import envpool
import numpy as np

env = envpool.make_gym("Pong-v5", num_envs=2)

action_num = env.action_space.n

action = np.random.randint(action_num, size=2)
obs, rew, done, info = env.step(action)

print(info["env_id"]) 

Expected behavior

The expected output is [1, 2] but I keep getting [0, 0] for some reason.

System info

Describe the characteristic of your environment:

import envpool, numpy, sys
print(envpool.__version__, numpy.__version__, sys.version, sys.platform)

0.8.4 2.0.0 3.10.12 (main, Jul 29 2024, 16:56:48) [GCC 11.4.0] linux

Checklist

RajGhugare19 commented 2 months ago

I think this issue occurs because of some interplay between envpool and numpy==2.0.1. I downgraded to numpy==1.26.0 and it works now.

lionelblonde commented 3 weeks ago

To add on to the issue/bug description: whatever the number of environment the pool, a call to reset would get me a numpy array where all the values where identical (across the observation and across the pool dimension). I was using numpy==2.0.1. Thanks to the previous comment, I changed to numpy==1.26.0, and the phenomenon I have just described does not occur anymore.