huggingface / huggingface/deep-rl-class
[HANDS-ON BUG] Unit 1 Load a saved LunarLander...
- Dominant language
- MDX
- Stars
- 5k
- Forks
- 811
- PR merge metrics
- No merged PRs in 30d
Description
# Describe the bug
A clear and concise description of what the bug is.
Running the following code:
```
!pip install shimmy
```
Colab prompts for session restart due to conflicting dependencies. After that, the dependencies do not load correctly and the example of acquiring the model from the hub and evaluating it is broken.
```
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
stable-baselines3 2.0.0a5 requires gymnasium==0.28.1, but you have gymnasium 1.2.0 which is incompatible.
Successfully installed gymnasium-1.2.0
WARNING: The following packages were previously imported in this runtime:
[gymnasium]
You must restart the runtime in order to use newly installed versions.
```
So the following does not work.
```
from huggingface_sb3 import load_from_hub
repo_id = "Classroom-workshop/assignment2-omar" # The repo_id
filename = "ppo-LunarLander-v2.zip" # The model filename.zip
# When the model was trained on Python 3.8 the pickle protocol is 5
# But Python 3.6, 3.7 use protocol 4
# In order to get compatibility we need to:
# 1. Install pickle5 (we done it at the beginning of the colab)
# 2. Create a custom empty object we pass as parameter to PPO.load()
custom_objects = {
"learning_rate": 0.0,
"lr_schedule": lambda _: 0.0,
"clip_range": lambda _: 0.0,
}
checkpoint = load_from_hub(repo_id, filename)
model = PPO.load(checkpoint, custom_objects=custom_objects, print_system_info=True)
```
It results with the error:
```
Gym has been unmaintained since 2022 and does not support NumPy 2.0 amongst other critical functionality.
Please upgrade to Gymnasium, the maintained drop-in replacement of Gym, or contact the authors of your software and request that they upgrade.
See the migration guide at https://gymnasium.farama.org/introduction/migration_guide/ for additional information.
---------------------------------------------------------------------------
ModuleNotFoundError Traceback (most recent call last)
[/tmp/ipython-input-3890402073.py](https://localhost:8080/#) in ()
----> 1 from huggingface_sb3 import load_from_hub
2 repo_id = "Classroom-workshop/assignment2-omar" # The repo_id
3 filename = "ppo-LunarLander-v2.zip" # The model filename.zip
4
5 # When the model was trained on Python 3.8 the pickle protocol is 5
12 frames
[/usr/local/lib/python3.11/dist-packages/stable_baselines3/common/vec_env/vec_video_recorder.py](https://localhost:8080/#) in
2 from typing import Callable
3
----> 4 from gymnasium.wrappers.monitoring import video_recorder
5
6 from stable_baselines3.common.vec_env.base_vec_env import VecEnv, VecEnvObs, VecEnvStepReturn, VecEnvWrapper
ModuleNotFoundError: No module named 'gymnasium.wrappers.monitoring'
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
```
# Material
- Did you use Google Colab? Yes
## Feedback
Splitting the notebook into smaller units might help.
Or maybe introduce the relevant imports per smaller unit...
In any case, these examples do not work as intended.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.