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

Error running the Asterix environment #83

Open
ID-Akash opened this issue Aug 13, 2024 · 1 comment
Open

Error running the Asterix environment #83

ID-Akash opened this issue Aug 13, 2024 · 1 comment

Comments

@ID-Akash
Copy link

Hello,

I am trying to train a RL agent in JAX for Asterix-Minatar, however, I get the following error:

File "/opt/miniconda3/envs/minasa/lib/python3.11/site-packages/gymnax/wrappers/gym.py", line 70, in step o, self.env_state, r, d, info = self._env.step( ^^^^^^^^^^^^^^^ File "/opt/miniconda3/envs/minasa/lib/python3.11/site-packages/gymnax/environments/environment.py", line 45, in step obs_st, state_st, reward, done, info = self.step_env(key, state, action, params) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/envs/minasa/lib/python3.11/site-packages/gymnax/environments/minatar/asterix.py", line 108, in step_env state, reward, done = step_entities(state) ^^^^^^^^^^^^^^^^^^^^ File "/opt/miniconda3/envs/minasa/lib/python3.11/site-packages/gymnax/environments/minatar/asterix.py", line 335, in step_entities bool(done > 0), ^^^^^^^^^^^^^^ jax.errors.TracerBoolConversionError: Attempted boolean conversion of traced array with shape bool[].. The error occurred while tracing the function step at /opt/miniconda3/envs/minasa/lib/python3.11/site-packages/gymnax/environments/environment.py:32 for jit. This concrete value was not available in Python because it depends on the values of the arguments self, key.player_x, key.player_y, key.spawn_timer, key.move_timer, key.entities, and state. See https://jax.readthedocs.io/en/latest/errors.html#jax.errors.TracerBoolConversionError

The same code works fine with SpaceInvaders and Breakout environments. I think that because the done flag depends on the state, jax is unable to jit the step function.

I am using python 3.11 and jax 0.4.23.

@JackZhangY
Copy link

Refer to the code in the 'main' branch to fix some small debugs that exist in version v0.0.8,
e.g., line 335 in 'asterix.py':
bool(done > 0) --> jnp.bool_(done > 0)

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