Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Blank output for numpy 2.0.0 #321

Open
3 tasks done
jsonmona opened this issue Dec 15, 2024 · 0 comments
Open
3 tasks done

[BUG] Blank output for numpy 2.0.0 #321

jsonmona opened this issue Dec 15, 2024 · 0 comments
Assignees

Comments

@jsonmona
Copy link

Describe the bug

Atari environment produces blank output when having numpy>=2 installed.

Installing numpy<2 (which resolves to numpy-1.26.4-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl) fixes the issue.

Here, blank output means RGB (0, 0, 0) for Breakout-v5.
Pong-v5 produces RGB (89, 89, 89) instead.

To Reproduce

pip install -U envpool opencv-python

# To fix the issue:
pip install -U 'numpy<2'

# To reproduce the issue:
pip install -U 'numpy>=2'
import numpy as np
import envpool
import cv2

env_id = "Pong-v5"

# gray_scale does not affect this issue
env = envpool.make_gymnasium(
    env_id,
    num_envs=16,
    max_episode_steps=3600,
    stack_num=1,
    gray_scale=False,
    episodic_life=True,
    repeat_action_probability=0.25,
    use_fire_reset=True,
)

for _ in range(1000):
    next_obs, reward, terminations, truncations, infos = env.step(np.zeros(args.num_envs, dtype="int32"))
    cv2.imshow("img", np.moveaxis(next_obs[0], 0, -1))
    cv2.waitKey(10)

Expected behavior

Either work with numpy 2 or declare to not support numpy>2.

System info

Describe the characteristic of your environment:

  • Installed via pip inside venv
  • Using python 3.10.12
  • Working inside WSL 2 (Windows Subsystem Linux)
import envpool, numpy, sys
print(envpool.__version__, numpy.__version__, sys.version, sys.platform)
# 0.8.4 1.26.4 3.10.12 (main, Nov  6 2024, 20:22:13) [GCC 11.4.0] linux

Reason and Possible fixes

This project declares support for any numpy version. That is broken by design as numpy bumping its major version can cause issue at any time. It is extra confusing as things work perfectly for people who have not upgraded numpy yet.

While this issue should be fixed at some point, I think adding numpy<2 is good for now. With that being said, I propose to add version constraint like <2 to prevent upgrading major version for every dependency that is not alpha (e.g. 0.1.2).

If you plan to tackle on the root cause of this issue, this article from numpy documentation might be helpful.

Checklist

  • I have checked that there is no similar issue in the repo (required)
  • I have read the documentation (required)
  • I have provided a minimal working example to reproduce the bug (required)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants