EdanToledo / Stoix

🏛️A research-friendly codebase for fast experimentation of single-agent reinforcement learning in JAX • End-to-End JAX RL
Apache License 2.0
230 stars 24 forks source link

[BUG] 'CartPole' object has no attribute 'reward_spec' #34

Closed MichaelTMatthews closed 7 months ago

MichaelTMatthews commented 7 months ago

Describe the bug

Following the instructions from the README to install and then running the example python stoix/systems/ppo/ff_ppo.py crashes with the following error:

AttributeError: 'CartPole' object has no attribute 'reward_spec'

To Reproduce

Steps to reproduce the behavior:

  1. Run python stoix/systems/ppo/ff_ppo.py

Context (Environment)

Python version: 3.10 OS: Ubuntu 22.04 Pip freeze:

absl-py==2.0.0
antlr4-python3-runtime==4.9.3
appdirs==1.4.4
apturl==0.5.2
arch==5.3.0
arrow==1.3.0
arxiv_latex_cleaner==1.0.4
asttokens==2.4.1
astunparse==1.6.3
attrs==23.2.0
bcrypt==3.2.0
black==23.3.0
blinker==1.7.0
boto3==1.34.67
botocore==1.34.67
bravado==11.0.3
bravado-core==6.1.1
brax==0.10.3
Brlapi==0.8.3
cachetools==5.3.2
certifi==2020.6.20
cffi==1.16.0
cfgv==3.4.0
chardet==4.0.0
chex==0.1.86
click==8.1.7
cloudpickle==3.0.0
colorama==0.4.4
colorcet==3.0.0
coloredlogs==15.0.1
command-not-found==0.3
configobj==5.0.6
contextlib2==21.6.0
contourpy==1.2.0
craftax @ git+https://github.com/MichaelTMatthews/Craftax.git@9b5aa78078f970d4fbf99a2b64c8893449acecd0
crafter==1.7.1
cryptography==3.4.8
cupshelpers==1.0
cycler==0.12.1
Cython==0.29.37
-e git+https://github.com/rail-berkeley/d4rl.git@71a9549f2091accff93eeff68f1f3ab2c0e0a288#egg=D4RL
daemoniker==0.2.3
dbus-python==1.2.18
decorator==5.1.1
defer==1.0.6
dill==0.3.7
distlib==0.3.7
distrax @ git+https://github.com/google-deepmind/distrax@ee17707c419766252386da3337f24751a6d12905
distro==1.7.0
distro-info==1.1+ubuntu0.2
dm-control==1.0.5
dm-env==1.6
dm-tree==0.1.8
docker-pycreds==0.4.0
dotmap==1.3.30
duplicity==0.8.21
etils==1.5.2
evosax==0.1.6
exceptiongroup==1.2.0
executing==2.0.1
fasteners==0.19
filelock==3.13.1
flaky==3.7.0
flashbax @ git+https://github.com/instadeepai/flashbax@2b8354df94f48dfdb7818b6822c8c126729fec4d
Flask==3.0.2
Flask-Cors==4.0.0
flatbuffers==23.5.26
flax==0.8.2
fonttools==4.48.1
fqdn==1.5.1
fsspec==2023.12.1
future==0.18.2
gast==0.4.0
getch==1.0
gitdb==4.0.11
GitPython==3.1.40
glfw==2.6.4
google-auth==2.26.1
google-auth-oauthlib==0.4.6
google-pasta==0.2.0
grpcio==1.60.0
gym==0.26.2
gym-notices==0.0.8
gymnax==0.0.6
gyp==0.1
h5py==3.10.0
httplib2==0.20.2
huggingface-hub==0.21.4
humanfriendly==10.0
hydra-core==1.3.2
id-marl-eval @ git+https://github.com/instadeepai/marl-eval@63895c91e089f1164afb9aac1821968cdae69fc8
identify==2.5.27
idna==3.3
ImageHash==4.3.1
imageio==2.34.0
importlib-metadata==4.6.4
importlib-resources==6.1.1
inflection==0.5.1
ipython==8.20.0
isoduration==20.11.0
itsdangerous==2.1.2
jax==0.4.25
jaxlib==0.4.25+cuda12.cudnn89
jaxmarl==0.0.2
jaxopt==0.8.3
jedi==0.19.1
jeepney==0.7.1
Jinja2==3.1.3
jmespath==1.0.1
jsonpointer==2.4
jsonref==1.1.0
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
jumanji @ git+https://github.com/instadeepai/jumanji.git@1f38fe669c31d0f41a51e23ff02e74e300bb89c9
keras==2.11.0
keyring==23.5.0
kiwisolver==1.4.5
labmaze==1.0.6
language-selector==0.1
launchpadlib==1.10.16
lazr.restfulclient==0.14.4
lazr.uri==1.0.6
libclang==16.0.6
lockfile==0.12.2
louis==3.20.0
lxml==5.0.1
macaroonbakery==1.3.1
Mako==1.1.3
Markdown==3.5.1
markdown-it-py==3.0.0
MarkupSafe==2.1.3
matplotlib==3.7.5
matplotlib-inline==0.1.6
mctx==0.0.5
mdurl==0.1.2
minerl @ git+https://github.com/minerllabs/minerl@8268ee99329ab45793859050d95352d35274532b
mjrl @ git+https://github.com/aravindr93/mjrl@3871d93763d3b49c4741e6daeaebbc605fe140dc
ml-collections==0.1.1
ml-dtypes==0.3.1
monotonic==1.6
more-itertools==8.10.0
msgpack==1.0.7
mujoco==3.1.3
mujoco-mjx==3.1.3
mujoco-py==2.1.2.14
mypy-extensions==1.0.0
neptune==1.9.1
nest-asyncio==1.5.8
netifaces==0.11.0
nodeenv==1.8.0
numpy==1.26.4
nvidia-cublas-cu12==12.3.4.1
nvidia-cuda-cupti-cu12==12.3.101
nvidia-cuda-nvcc-cu12==12.4.99
nvidia-cuda-nvrtc-cu12==12.3.103
nvidia-cuda-runtime-cu12==12.3.101
nvidia-cudnn-cu12==8.9.7.29
nvidia-cufft-cu12==11.0.12.1
nvidia-cusolver-cu12==11.5.4.101
nvidia-cusparse-cu12==12.2.0.103
nvidia-nccl-cu12==2.19.3
nvidia-nvjitlink-cu12==12.3.101
oauthlib==3.2.0
olefile==0.46
omegaconf==2.3.0
opencv-python==4.9.0.80
opensimplex==0.4.5
opt-einsum==3.3.0
optax==0.1.5
orbax-checkpoint==0.4.4
packaging==23.2
pandas==1.4.4
param==2.0.2
paramiko==2.9.3
parso==0.8.3
pathspec==0.12.1
patsy==0.5.6
pexpect==4.8.0
pillow==10.2.0
platformdirs==3.10.0
plumbum==1.8.2
pre-commit==3.3.3
prompt-toolkit==3.0.43
property-cached==1.6.4
protobuf==3.19.6
psutil==5.9.0
ptyprocess==0.7.0
pure-eval==0.2.2
pyasn1==0.5.1
pyasn1-modules==0.3.0
pybullet==3.2.6
pycairo==1.20.1
pycparser==2.21
pyct==0.5.0
pycups==2.0.1
pygame==2.5.2
pyglet==2.0.10
Pygments==2.17.2
PyGObject==3.42.1
PyJWT==2.3.0
pymacaroons==0.13.0
PyNaCl==1.5.0
PyOpenGL==3.1.7
pyparsing==2.4.7
pyrallis==0.3.1
pyRFC3339==1.1
Pyro4==4.82
python-apt==2.4.0+ubuntu3
python-dateutil==2.8.1
python-debian==0.1.43+ubuntu1.1
pytinyrenderer==0.0.14
pytz==2022.1
PyWavelets==1.5.0
pyxdg==0.27
PyYAML==6.0.1
referencing==0.34.0
regex==2023.12.25
reportlab==3.6.8
requests==2.25.1
requests-oauthlib==1.3.1
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.7.0
rlax==0.1.6
rliable==1.0.8
rpds-py==0.18.0
rsa==4.9
ruamel.yaml==0.17.40
ruamel.yaml.clib==0.2.8
s3transfer==0.10.1
safetensors==0.4.2
scipy==1.11.4
screen-resolution-extra==0.0.0
seaborn==0.13.2
SecretStorage==3.3.1
sentry-sdk==1.38.0
serpent==1.41
setproctitle==1.3.3
simplejson==3.19.2
six==1.16.0
smmap==5.0.1
stack-data==0.6.3
statsmodels==0.14.1
-e git+https://github.com/EdanToledo/Stoix.git@781b5d235fd2b3227452e3e87cd2f9b27ba1ce8e#egg=Stoix
swagger-spec-validator==3.0.3
systemd-python==234
tdqm==0.0.1
tensorboard==2.11.2
tensorboard-data-server==0.6.1
tensorboard-logger==0.1.0
tensorboard-plugin-wit==1.8.1
tensorboardX==2.6
tensorflow==2.11.1
tensorflow-estimator==2.11.0
tensorflow-io-gcs-filesystem==0.35.0
tensorflow-probability==0.19.0
tensorstore==0.1.56
termcolor==2.4.0
terminator==2.1.3
tomli==2.0.1
toolz==0.12.0
tqdm==4.66.1
traitlets==5.14.1
trimesh==4.2.0
types-python-dateutil==2.9.0.20240316
typing==3.7.4.3
typing-inspect==0.9.0
typing_extensions==4.10.0
ubuntu-advantage-tools==8001
ubuntu-drivers-common==0.0.0
ufw==0.36.1
unattended-upgrades==0.1
uri-template==1.3.0
urllib3==2.1.0
usb-creator==0.3.7
virtualenv==20.24.4
wadllib==1.3.6
wandb==0.16.3
wcwidth==0.2.13
webcolors==1.13
websocket-client==1.7.0
Werkzeug==3.0.1
wrapt==1.16.0
xdg==5
xkit==0.0.0
xminigrid @ git+https://github.com/corl-team/xland-minigrid.git@e07118a8421c15e26abb4e0b21d74e4591a9a3af
xmltodict==0.12.0
zipp==1.0.0
EdanToledo commented 7 months ago

This confuses me 😅 are you simply just running the ppo file with its default configs?

I'll install your environment and see if the same issue occurs for me.

EdanToledo commented 7 months ago

I'm struggling to find the reason as to why this is occurring for you. Regardless, I've implemented a small change explicitly defining the reward spec function for the wrappers. Let me know if that fixes the issue for you. Additionally, I'll link my local pip freeze output as well for you to look at although i don't see anything that stands out as a cause for concern.

antlr4-python3-runtime==4.9.3
appdirs==1.4.4
arch==5.3.0
arrow==1.3.0
astunparse==1.6.3
attrs==23.2.0
black==24.3.0
blinker==1.7.0
boto3==1.34.65
botocore==1.34.65
bravado==11.0.3
bravado-core==6.1.1
brax==0.10.3
cachetools==5.3.2
certifi==2024.2.2
cfgv==3.4.0
charset-normalizer==3.3.2
chex==0.1.85
click==8.1.7
cloudpickle==3.0.0
colorama==0.4.6
colorcet==3.0.0
contextlib2==21.6.0
contourpy==1.2.0
craftax==1.1.1
cycler==0.12.1
decorator==5.1.1
distlib==0.3.8
distrax @ git+https://github.com/google-deepmind/distrax@ee17707c419766252386da3337f24751a6d12905
dm-env==1.6
dm-tree==0.1.8
docker-pycreds==0.4.0
dotmap==1.3.30
etils==1.7.0
evosax==0.1.6
filelock==3.13.1
flashbax @ git+https://github.com/instadeepai/flashbax@2b8354df94f48dfdb7818b6822c8c126729fec4d
Flask==3.0.2
Flask-Cors==4.0.0
flatbuffers==23.5.26
flax==0.8.1
fonttools==4.50.0
fqdn==1.5.1
fsspec==2024.2.0
future==1.0.0
gast==0.5.4
gitdb==4.0.11
GitPython==3.1.42
glfw==2.6.5
google-auth==2.28.1
google-auth-oauthlib==1.2.0
google-pasta==0.2.0
grpcio==1.62.0
gym==0.26.2
gym-notices==0.0.8
gymnax==0.0.6
h5py==3.10.0
huggingface-hub==0.21.4
hydra-core==1.3.2
id-marl-eval @ git+https://github.com/instadeepai/marl-eval@63895c91e089f1164afb9aac1821968cdae69fc8
identify==2.5.35
idna==3.6
imageio==2.34.0
importlib-metadata==4.13.0
importlib-resources==6.1.1
isoduration==20.11.0
itsdangerous==2.1.2
jax==0.4.24
jaxlib==0.4.24
jaxmarl==0.0.2
jaxopt==0.8.3
Jinja2==3.1.3
jmespath==1.0.1
jsonpointer==2.4
jsonref==1.1.0
jsonschema==4.21.1
jsonschema-specifications==2023.12.1
jumanji==1.0.0
keras==2.15.0
kiwisolver==1.4.5
libclang==16.0.6
Markdown==3.5.2
markdown-it-py==3.0.0
MarkupSafe==2.1.5
matplotlib==3.7.5
mctx==0.0.5
mdurl==0.1.2
ml-collections==0.1.1
ml-dtypes==0.3.2
monotonic==1.6
msgpack==1.0.7
mujoco==3.1.3
mujoco-mjx==3.1.3
mypy==1.9.0
mypy-extensions==1.0.0
neptune==1.9.1
nest-asyncio==1.6.0
nodeenv==1.8.0
numpy==1.26.4
oauthlib==3.2.2
omegaconf==2.3.0
opt-einsum==3.3.0
optax==0.1.9
orbax-checkpoint==0.5.3
packaging==23.2
pandas==1.4.4
param==2.0.2
pathspec==0.12.1
patsy==0.5.6
pgx==2.0.1
pgx-minatar==0.5.1
pillow==10.2.0
platformdirs==4.2.0
pre-commit==3.6.2
property-cached==1.6.4
protobuf==3.20.1
psutil==5.9.8
pyasn1==0.5.1
pyasn1-modules==0.3.0
pyct==0.5.0
pygame==2.5.2
Pygments==2.17.2
PyJWT==2.8.0
PyOpenGL==3.1.7
pyparsing==3.1.2
python-dateutil==2.9.0.post0
pytinyrenderer==0.0.14
pytz==2024.1
PyYAML==6.0.1
referencing==0.34.0
requests==2.31.0
requests-oauthlib==1.3.1
rfc3339-validator==0.1.4
rfc3986-validator==0.1.1
rich==13.7.0
rlax==0.1.6
rliable==1.0.8
rpds-py==0.18.0
rsa==4.9
s3transfer==0.10.1
safetensors==0.4.2
scipy==1.12.0
seaborn==0.13.2
sentry-sdk==1.42.0
setproctitle==1.3.3
simplejson==3.19.2
six==1.16.0
smmap==5.0.1
statsmodels==0.14.1
-e git+https://github.com/EdanToledo/Stoix.git@f8ea18944229bdac8ab04c61f3336a2faef06cbf#egg=Stoix
svgwrite==1.4.3
swagger-spec-validator==3.0.3
tdqm==0.0.1
tensorboard==2.15.2
tensorboard-data-server==0.7.2
tensorboard-logger==0.1.0
tensorboardX==2.6.2.2
tensorflow-estimator==2.15.0
tensorflow-io-gcs-filesystem==0.36.0
tensorflow-probability==0.24.0
tensorstore==0.1.53
termcolor==2.4.0
tomli==2.0.1
toolz==0.12.1
tqdm==4.66.2
trimesh==3.9.35
types-python-dateutil==2.9.0.20240316
typing_extensions==4.9.0
uri-template==1.3.0
urllib3==2.2.1
virtualenv==20.25.1
wandb==0.16.4
webcolors==1.13
websocket-client==1.7.0
Werkzeug==3.0.1
wrapt==1.14.1
xminigrid @ git+https://github.com/corl-team/xland-minigrid.git@e07118a8421c15e26abb4e0b21d74e4591a9a3af
zipp==3.17.0

Additionally, i don't see version differences causing something like this, what are you creating your python environment with?

MichaelTMatthews commented 7 months ago

Thanks, that works now! For posterity, I was using a PyCharm venv and yes just running with the default config