Skip to content

Commit d0c1a87

Browse files
Bonifatius94qgallouedecaraffin
authored
Add scaling section to A2C documentation (#1250)
* add scaling section to A2C documentation * add cross-reference to vectorized envs article * turn it as note * update changelog * add Bonifatius94 to the list of contributors * fix issue number --------- Co-authored-by: Quentin Gallouédec <[email protected]> Co-authored-by: Quentin GALLOUÉDEC <[email protected]> Co-authored-by: Antonin RAFFIN <[email protected]>
1 parent 82bc63f commit d0c1a87

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

docs/misc/changelog.rst

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Others:
3939
Documentation:
4040
^^^^^^^^^^^^^^
4141
- Renamed ``load_parameters`` to ``set_parameters`` (@DavyMorgan)
42+
- Clarified documentation about subproc multiprocessing for A2C (@Bonifatius94)
4243
- Fixed typo in ``A2C`` docstring (@AlexPasqua)
4344

4445

@@ -1222,4 +1223,4 @@ And all the contributors:
12221223
@Gregwar @ycheng517 @quantitative-technologies @bcollazo @git-thor @TibiGG @cool-RR @MWeltevrede
12231224
@Melanol @qgallouedec @francescoluciano @jlp-ue @burakdmb @timothe-chaumont @honglu2875 @yuanmingqi
12241225
@anand-bala @hughperkins @sidney-tio @AlexPasqua @dominicgkerr @Akhilez @Rocamonde @tobirohrer @ZikangXiong
1225-
@DavyMorgan @luizapozzobon
1226+
@DavyMorgan @luizapozzobon @Bonifatius94

docs/modules/a2c.rst

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,24 @@ Train a A2C agent on ``CartPole-v1`` using 4 environments.
7676
env.render()
7777
7878
79+
.. note::
80+
81+
A2C is meant to be run primarily on the CPU, especially when you are not using a CNN. To improve CPU utilization, try turning off the GPU and using ``SubprocVecEnv`` instead of the default ``DummyVecEnv``:
82+
83+
.. code-block::
84+
85+
from stable_baselines3 import A2C
86+
from stable_baselines3.common.env_util import make_vec_env
87+
from stable_baselines3.common.vec_env import SubprocVecEnv
88+
89+
if __name__=="__main__":
90+
env = make_vec_env("CartPole-v1", n_envs=8, vec_env_cls=SubprocVecEnv)
91+
model = A2C("MlpPolicy", env, device="cpu")
92+
model.learn(total_timesteps=25_000)
93+
94+
For more information, see :ref:`Vectorized Environments <vec_env>`, `Issue #1245 <https://github.com/DLR-RM/stable-baselines3/issues/1245>`_ or the `Multiprocessing notebook <https://colab.research.google.com/github/Stable-Baselines-Team/rl-colab-notebooks/blob/sb3/multiprocessing_rl.ipynb>`_.
95+
96+
7997
Results
8098
-------
8199

0 commit comments

Comments
 (0)