araffin / rl-tutorial-jnrr19

Stable-Baselines tutorial for Journées Nationales de la Recherche en Robotique 2019
MIT License
591 stars 113 forks source link

ValueError: high is out of bounds for int32 on 5_custom_gym_env.ipynb #20

Closed NVentimiglia closed 1 year ago

NVentimiglia commented 1 year ago

When trying to run 5_custom_gym_env.ipynb I got an error when running vec_env = make_vec_env(GoLeftEnv, n_envs=1, env_kwargs=dict(grid_size=10)).

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
Cell In[14], line 5
      2 from stable_baselines3.common.env_util import make_vec_env
      4 # Instantiate the env
----> 5 vec_env = make_vec_env(GoLeftEnv, n_envs=1, env_kwargs=dict(grid_size=10))

File [~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\stable_baselines3\common\env_util.py:127](https://file+.vscode-resource.vscode-cdn.net/d%3A/Projects/StockDev/gym-dev/examples/~/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0/LocalCache/local-packages/Python39/site-packages/stable_baselines3/common/env_util.py:127), in make_vec_env(env_id, n_envs, seed, start_index, monitor_dir, wrapper_class, env_kwargs, vec_env_cls, vec_env_kwargs, monitor_kwargs, wrapper_kwargs)
    125 vec_env = vec_env_cls([make_env(i + start_index) for i in range(n_envs)], **vec_env_kwargs)
    126 # Prepare the seeds for the first reset
--> 127 vec_env.seed(seed)
    128 return vec_env

File [~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\stable_baselines3\common\vec_env\base_vec_env.py:281](https://file+.vscode-resource.vscode-cdn.net/d%3A/Projects/StockDev/gym-dev/examples/~/AppData/Local/Packages/PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0/LocalCache/local-packages/Python39/site-packages/stable_baselines3/common/vec_env/base_vec_env.py:281), in VecEnv.seed(self, seed)
    268 """
    269 Sets the random seeds for all environments, based on a given seed.
    270 Each individual environment will still get its own seed, by incrementing the given seed.
   (...)
    276     Note that all list elements may be None, if the env does not return anything when being seeded.
    277 """
    278 if seed is None:
    279     # To ensure that subprocesses have different seeds,
    280     # we still populate the seed variable when no argument is passed
--> 281     seed = np.random.randint(0, 2**32 - 1)
    283 self._seeds = [seed + idx for idx in range(self.num_envs)]
...
File mtrand.pyx:746, in numpy.random.mtrand.RandomState.randint()

File _bounded_integers.pyx:1336, in numpy.random._bounded_integers._rand_int32()

ValueError: high is out of bounds for int32
Output is truncated. View as a [scrollable element](command:cellOutput.enableScrolling?56965ff2-f146-40a9-b2b8-1277a85484d0) or open in a [text editor](command:workbench.action.openLargeOutput?56965ff2-f146-40a9-b2b8-1277a85484d0). Adjust cell output [settings](command:workbench.action.openSettings?%5B%22%40tag%3AnotebookOutputLayout%22%5D)...

installs

Collecting stable-baselines3[extra]>=2.0.0a4
  Using cached stable_baselines3-2.0.0-py3-none-any.whl (178 kB)
Requirement already satisfied: gymnasium==0.28.1 in c:\users\nvent\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from stable-baselines3[extra]>=2.0.0a4) (0.28.1)
Requirement already satisfied: numpy>=1.20 in c:\users\nvent\appdata\local\packages\pythonsoftwarefoundation.python.3.9_qbz5n2kfra8p0\localcache\local-packages\python39\site-packages (from stable-baselines3[extra]>=2.0.0a4) (1.23.5)
araffin commented 1 year ago

Hello, i guess you are using Windows ?

araffin commented 1 year ago

You can use Google colab in the meantime, the issue is there: https://github.com/DLR-RM/stable-baselines3/issues/1579

NVentimiglia commented 1 year ago

Hello, i guess you are using Windows ?

Yes, windows

NVentimiglia commented 1 year ago

You can use Google colab in the meantime, the issue is there: DLR-RM/stable-baselines3#1579

I see the work around! thanks!