huggingface / deep-rl-class

This repo contains the syllabus of the Hugging Face Deep Reinforcement Learning Course.
Apache License 2.0
3.73k stars 568 forks source link

[HANDS-ON BUG]AttributeError: 'dict' object has no attribute 'env_specs' #383

Closed 1995lb closed 8 months ago

1995lb commented 11 months ago

Describe the bug

A bug happens when i try to upload my model to hub,the error just likes this: 22 eval_env = DummyVecEnv([lambda: Monitor(gym.make(env_id, render_mode="rgb_array"))]) ---> 24 package_to_hub( 26 model=model, 28 model_name=model_name, 30 model_architecture=model_architecture, 32 env_id=env_id, 34 eval_env=eval_env, 36 repo_id=repo_id, 37 commit_message=commit_message, 38 )

File /opt/conda/lib/python3.10/site-packages/huggingface_sb3/push_to_hub.py:366, in package_to_hub(model, model_name, model_architecture, env_id, eval_env, repo_id, commit_message, is_deterministic, n_eval_episodes, token, video_length, logs) 364 # Deterministic by default (except for Atari) 365 if is_deterministic: --> 366 is_deterministic = not is_atari(env_id) 368 # Step 2: Create a config file 369 _generate_config(model_name, tmpdirname)

File /opt/conda/lib/python3.10/site-packages/huggingface_sb3/push_to_hub.py:104, in is_atari(env_id) 98 def is_atari(env_id: str) -> bool: 99 """ 100 Check if the environment is an Atari one 101 (Taken from RL-Baselines3-zoo) 102 :param env_id: name of the environment 103 """ --> 104 entry_point = gym.envs.registry.env_specs[env_id].entry_point 105 return "AtariEnv" in str(entry_point)

AttributeError: 'dict' object has no attribute 'env_specs'

i have done some search,the version of gym may not match.

Material

If not: i am using kaggle, gpu T4

simoninithomas commented 11 months ago

Hey there 👋 which hands on are you working on?

If you use huggingface_sb3 we didn't published the new release yet but you can install it using pip install git+https://github.com/huggingface/huggingface_sb3@gymnasium-v2

simoninithomas commented 10 months ago

Edit, we published the new release you can install using pip install huggingface-sb3

1995lb commented 10 months ago

Edit, we published the new release you can install using pip install huggingface-sb3 Thanks,I will try it again.

SDcodehub commented 10 months ago

facing same issue, working on unit 6, cpu windows, 64.

tried installing latest version of huggingface-sb3, did not work.

AttributeError: 'dict' object has no attribute 'env_specs'

SDcodehub commented 10 months ago

short snippet of traceback

following git issue may help - https://github.com/openai/gym/issues/3097

File [c:\Users\Admin\Desktop\work\huggingface\.conda\Lib\site-packages\huggingface_sb3\push_to_hub.py:104](file:///C:/Users/Admin/Desktop/work/huggingface/.conda/Lib/site-packages/huggingface_sb3/push_to_hub.py:104), in is_atari(env_id)
     98 def is_atari(env_id: str) -> bool:
     99     """
    100     Check if the environment is an Atari one
    101     (Taken from RL-Baselines3-zoo)
    102     :param env_id: name of the environment
    103     """
--> 104     entry_point = gym.envs.registry.env_specs[env_id].entry_point
    105     return "AtariEnv" in str(entry_point)
simoninithomas commented 10 months ago

Which version of huggingface-sb3 you have?

SDcodehub commented 10 months ago

Did not specify perticular version, so should pull latest 2.3

simoninithomas commented 10 months ago

Hey there 👋 did you tried again with the update v3.0?

1995lb commented 9 months ago

yes, but i got the same result,maybe i did something wrong.  

菲关癖爱轻模样 @.***

 

------------------ 原始邮件 ------------------ 发件人: "Thomas @.>; 发送时间: 2023年9月13日(星期三) 下午5:18 收件人: @.>; 抄送: @.>; @.>; 主题: Re: [huggingface/deep-rl-class] [HANDS-ON BUG]AttributeError: 'dict' object has no attribute 'env_specs' (Issue #383)

Hey there 👋 did you tried again with the update v3.0?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>