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

Unable to train on many agents #118

Closed
hmomin opened this issue Mar 3, 2022 · 8 comments
Closed

Unable to train on many agents #118

hmomin opened this issue Mar 3, 2022 · 8 comments
Assignees
Labels
bug Something isn't working

Comments

@hmomin
Copy link
Contributor

hmomin commented Mar 3, 2022

Whenever I try to train on agents, I consistently get the error:

AttributeError: type object 'AgentXYZ' has no attribute 'if_off_policy'

For example, here is the error for AgentDQN:

Traceback (most recent call last):
  File "/home/momin/Documents/GitHub/ElegantRL/tests/test_training_agents.py", line 50, in test_should_create_arguments_for_each_agent
    Arguments(agent, env_func=gym.make, env_args=self.discrete_env_args)
  File "/home/momin/Documents/GitHub/ElegantRL/elegantrl/train/config.py", line 140, in __init__
    self.if_off_policy = agent.if_off_policy  # agent is on-policy or off-policy
AttributeError: type object 'AgentDQN' has no attribute 'if_off_policy'

I can confirm that this error affects the following agents:
AgentDQN
AgentD3QN
AgentDDPG
AgentDiscretePPO
AgentDoubleDQN
AgentDuelingDQN
AgentModSAC
AgentPPO_H
AgentPPO
AgentSAC_H
AgentSAC
AgentTD3

@shixun404

@hmomin
Copy link
Contributor Author

hmomin commented Mar 3, 2022

Shixun, if you'd like me to help out with this, I'm happy to. However, since I've noticed you're working very closely with the agents files, I'd prefer you handle this to avoid any merge conflicts between us. I'm mostly fixing some issues that have popped up related to Isaac Gym.

@shixun404
Copy link
Contributor

shixun404 commented Mar 3, 2022 via email

@YangletLiu YangletLiu added the bug Something isn't working label Mar 3, 2022
@richardhuo
Copy link

Same issue happened to me since yesterday tried to run FinRL via colab: Compare ElegantRL, RLlib, and Stablebaselines3.
the elegantrl package was no longer available from that time.
I managed to install the package from local but in the end received the same issue of : type object 'AgentXXX' has no attribute 'if_off_policy'

@yizhangliu
Copy link

ImportError: cannot import name 'SharePPO' from 'elegantrl.agents.net'

@hmomin
Copy link
Contributor Author

hmomin commented Mar 8, 2022

@richardhuo - that issue should be fixed by now, but you may be running into a different issue where agents cannot be imported from elegantrl.agent. I'll address it tomorrow...

@yizhangliu - that bug should be fixed now.

The original bug should also be fixed now in commit 5d95ce9.

@hmomin hmomin closed this as completed Mar 8, 2022
@farzinaghdam
Copy link

I am still experiencing this problem. It works fine on Colab. However on my local machine I get
File FinRL-Meta/agents/elegantrl_models.py", line 59, in get_model
model = Arguments(agent=agent, env=env)
File "python3.8/site-packages/elegantrl/train/config.py", line 127, in init
self.if_off_policy = agent.if_off_policy # agent is on-policy or off-policy
AttributeError: module 'elegantrl.agents.AgentPPO' has no attribute 'if_off_policy'

Thanks

@hmomin
Copy link
Contributor Author

hmomin commented May 7, 2022

@farzinaghdam
I suggest you try reinstalling ElegantRL on your local machine. I've just pulled the latest commit and all the relevant PPO tests are passing on my machine.

@farzinaghdam
Copy link

Thank you for quick reply.
I downgraded gym to 0.17.3 (which is the one used on my Colab at the moment) and reinstalled various packages and it works fine now. Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants