Skip to content

Commit 82f308c

Browse files
authored
[Doc] Fix doc rendering (#1112)
1 parent 50425ae commit 82f308c

File tree

11 files changed

+72
-75
lines changed

11 files changed

+72
-75
lines changed

docs/source/index.rst

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@ Basics
3838

3939
tutorials/coding_ppo
4040
tutorials/pendulum
41-
tutorials/tensordict_tutorial
42-
tutorials/tensordict_module
4341
tutorials/torchrl_demo
4442

4543
Intermediate
@@ -48,7 +46,7 @@ Intermediate
4846
.. toctree::
4947
:maxdepth: 1
5048

51-
tutorials/torch_envs
49+
tutorials/torchrl_envs
5250
tutorials/pretrained_models
5351
tutorials/dqn_with_rnn
5452

docs/source/reference/envs.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ It is now apparent that this can bring a significant speedup depending on the ki
237237
operations that is to be computed.
238238

239239
A great advantage of environment wrappers is that one can consult the environment up to that wrapper.
240-
The same can be achieved with TorchRL transformed environments: the :doc:`parent` attribute will
240+
The same can be achieved with TorchRL transformed environments: the ``parent`` attribute will
241241
return a new :class:`TransformedEnv` with all the transforms up to the transform of interest.
242242
Re-using the example above:
243243

@@ -248,15 +248,15 @@ Re-using the example above:
248248
249249
250250
Transformed environment can be used with vectorized environments.
251-
Since each transform uses a :doc:`"in_keys"`/:doc:`"out_keys"` set of keyword argument, it is
251+
Since each transform uses a ``"in_keys"``/``"out_keys"`` set of keyword argument, it is
252252
also easy to root the transform graph to each component of the observation data (e.g.
253253
pixels or states etc).
254254

255-
Transforms also have an :doc:`inv` method that is called before
255+
Transforms also have an ``inv`` method that is called before
256256
the action is applied in reverse order over the composed transform chain:
257257
this allows to apply transforms to data in the environment before the action is taken
258258
in the environment. The keys to be included in this inverse transform are passed through the
259-
:doc:`"in_keys_inv"` keyword argument:
259+
``"in_keys_inv"`` keyword argument:
260260

261261
.. code-block::
262262
:caption: Inverse transform

docs/source/reference/modules.rst

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,8 @@ Regular modules
305305
MLP
306306
ConvNet
307307
LSTMNet
308+
SqueezeLayer
309+
Squeeze2dLayer
308310

309311
Algorithm-specific modules
310312
~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -391,8 +393,3 @@ Utils
391393
mappings
392394
inv_softplus
393395
biased_softplus
394-
395-
.. currentmodule:: torchrl.modules.models.utils
396-
397-
SqueezeLayer
398-
Squeeze2dLayer

knowledge_base/HABITAT.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ print([_env for _env in HabitatEnv.available_envs if _env.startswith("Habitat")]
5252
```
5353

5454
2. `ImportError: /usr/lib/x86_64-linux-gnu/libOpenGL.so.0: undefined symbol: _glapi_tls_Current`
55-
**Solution**: as in [MUJOCO]([url](https://github.com/pytorch/rl/blob/main/knowledge_base/MUJOCO_INSTALLATION.md)) debug, Link conda to the right libOpenGL.so file (replace /path/to/conda and mujoco_env with the proper paths and names):
55+
**Solution**: as in [MUJOCO](https://github.com/pytorch/rl/blob/main/knowledge_base/MUJOCO_INSTALLATION.md) debug, Link conda to the right libOpenGL.so file (replace /path/to/conda and mujoco_env with the proper paths and names):
5656
```shell
5757
conda install -y -c conda-forge libglvnd-glx-cos7-x86_64 --force-reinstall
5858
conda install -y -c conda-forge xvfbwrapper --force-reinstall

knowledge_base/MUJOCO_INSTALLATION.md

Lines changed: 49 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,18 @@ $ python
119119
```
120120
This should trigger the building pipeline.
121121

122-
**Known issues**
122+
123+
**Sanity check**
124+
125+
To check that your mujoco-py has been built against the GPU, run
126+
```python
127+
>>> import mujoco_py
128+
>>> print(mujoco_py.cymj) # check it has the tag: linuxgpuextensionbuilder
129+
```
130+
The result should contain a filename with the tag `linuxgpuextensionbuilder`.
131+
132+
## Common Issues during import or when rendering Mujoco Environments
133+
123134
The above setup will most likely cause some problems. We give a list of known
124135
issues when running `import mujoco_py` and some troubleshooting for each of them:
125136

@@ -181,18 +192,8 @@ issues when running `import mujoco_py` and some troubleshooting for each of them
181192
_Solution_: This can usually be sovled by setting EGL as your mujoco_gl backend: `MUJOCO_GL=egl python myscript.py`
182193
183194
184-
**Sanity check**
185-
186-
To check that your mujoco-py has been built against the GPU, run
187-
```python
188-
>>> import mujoco_py
189-
>>> print(mujoco_py.cymj) # check it has the tag: linuxgpuextensionbuilder
190-
```
191-
The result should contain a filename with the tag `linuxgpuextensionbuilder`.
192-
193-
## Common Issues when rendering Mujoco Environments
194195
195-
1. RuntimeError with error stack like this when running jobs using schedulers like slurm:
196+
7. RuntimeError with error stack like this when running jobs using schedulers like slurm:
196197
197198
```
198199
File "mjrendercontext.pyx", line 46, in mujoco_py.cymj.MjRenderContext.__init__
@@ -209,59 +210,59 @@ RuntimeError: Failed to initialize OpenGL
209210
This can be worked around by setting the `GPUS` environment variable to the
210211
global device id. For slurm, it can be obtained using `SLURM_STEP_GPUS` enviroment variable.
211212
212-
2. Rendered images are completely black.
213+
8. Rendered images are completely black.
213214
214215
_Solution_: Make sure to call `env.render()` before reading the pixels.
215216
216-
3. `patchelf` dependency is missing.
217+
9. `patchelf` dependency is missing.
217218
218219
_Solution_: Install using `conda install patchelf` or `pip install patchelf`
219220
220-
4. Errors like "Onscreen rendering needs 101 device"
221+
10. Errors like "Onscreen rendering needs 101 device"
221222
222-
_Solution_: Make sure to set `DISPLAY` environment variable correctly.
223+
_Solution_: Make sure to set `DISPLAY` environment variable correctly.
223224
224-
5. `ImportError: Cannot initialize a headless EGL display.`
225+
11. `ImportError: Cannot initialize a headless EGL display.`
225226
226-
_Solution_: Make sure you have installed mujoco and all its dependencies (see instructions above).
227-
Make sure you have set the `MUJOCO_GL=egl`.
228-
Make sure you have a GPU accessible on your machine.
227+
_Solution_: Make sure you have installed mujoco and all its dependencies (see instructions above).
228+
Make sure you have set the `MUJOCO_GL=egl`.
229+
Make sure you have a GPU accessible on your machine.
229230
230-
6. `cannot find -lGL: No such file or directory`
231+
12. `cannot find -lGL: No such file or directory`
231232
232-
_Solution_: call `conda install -c anaconda mesa-libgl-devel-cos6-x86_64`
233+
_Solution_: call `conda install -c anaconda mesa-libgl-devel-cos6-x86_64`
233234
234-
7. ```
235-
RuntimeError: Failed to initialize OpenGL
236-
```
235+
13. ```
236+
RuntimeError: Failed to initialize OpenGL
237+
```
237238
238-
_Solution_: Install libEGL:
239+
_Solution_: Install libEGL:
239240
240-
- Ubuntu: `sudo apt install libegl-dev libegl`
241-
- CentOS: `sudo yum install mesa-libEGL mesa-libEGL-devel`
242-
- Conda: `conda install -c anaconda mesa-libegl-cos6-x86_64`
241+
- Ubuntu: `sudo apt install libegl-dev libegl`
242+
- CentOS: `sudo yum install mesa-libEGL mesa-libEGL-devel`
243+
- Conda: `conda install -c anaconda mesa-libegl-cos6-x86_64`
243244
244-
8. ```
245-
fatal error: X11/Xlib.h: No such file or directory
246-
| #include <X11/Xlib.h>
247-
| ^~~~~~~~~~~~
248-
```
245+
14. ```
246+
fatal error: X11/Xlib.h: No such file or directory
247+
| #include <X11/Xlib.h>
248+
| ^~~~~~~~~~~~
249+
```
249250
250-
_Solution_: Install X11:
251+
_Solution_: Install X11:
251252
252-
- Ubuntu: `sudo apt install libx11-dev`
253-
- CentOS: `sudo yum install libX11`
254-
- Conda: `conda install -c conda-forge xorg-libx11`
253+
- Ubuntu: `sudo apt install libx11-dev`
254+
- CentOS: `sudo yum install libX11`
255+
- Conda: `conda install -c conda-forge xorg-libx11`
255256
256-
9. ```
257-
fatal error: GL/osmesa.h: No such file or directory
258-
1 | #include <GL/osmesa.h>
259-
| ^~~~~~~~~~~~~
260-
compilation terminated.
261-
```
257+
15. ```
258+
fatal error: GL/osmesa.h: No such file or directory
259+
1 | #include <GL/osmesa.h>
260+
| ^~~~~~~~~~~~~
261+
compilation terminated.
262+
```
262263
263-
_Solution_: Install Osmesa:
264+
_Solution_: Install Osmesa:
264265
265-
10. Ubuntu: `sudo apt-get install libosmesa6-dev`
266-
11. CentOS: `sudo yum install mesa-libOSMesa-devel`
267-
12. Conda: `conda install -c menpo osmesa`
266+
- Ubuntu: `sudo apt-get install libosmesa6-dev`
267+
- CentOS: `sudo yum install mesa-libOSMesa-devel`
268+
- Conda: `conda install -c menpo osmesa`

torchrl/modules/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
Delta,
88
distributions_maps,
99
IndependentNormal,
10+
MaskedCategorical,
1011
NormalParamWrapper,
1112
OneHotCategorical,
1213
TanhDelta,

tutorials/sphinx-tutorials/coding_ddpg.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
#
1919
# To this aim, we will be focusing on DDPG, which is a relatively straightforward
2020
# algorithm to code.
21-
# DDPG (`Deep Deterministic Policy Gradient <https://arxiv.org/abs/1509.02971>_`_)
21+
# DDPG (`Deep Deterministic Policy Gradient <https://arxiv.org/abs/1509.02971>`_)
2222
# is a simple continuous control algorithm. It consists in learning a
2323
# parametric value function for an action-observation pair, and
2424
# then learning a policy that outputs actions that maximise this value
@@ -71,7 +71,7 @@
7171

7272
###############################################################################
7373
# torchrl :class:`~torchrl.objectives.LossModule`
74-
# ----------------------------------------------
74+
# -----------------------------------------------
7575
#
7676
# TorchRL provides a series of losses to use in your training scripts.
7777
# The aim is to have losses that are easily reusable/swappable and that have
@@ -614,8 +614,6 @@ def make_t_env():
614614
# training script when dealing with frame skipping as this may lead to
615615
# biased comparisons between training strategies.
616616
#
617-
618-
###############################################################################
619617
# Scaling the reward helps us control the signal magnitude for a more
620618
# efficient learning.
621619
reward_scaling = 5.0
@@ -963,7 +961,7 @@ def make_replay_buffer(buffer_size, batch_size, random_crop_len, prefetch=3, prb
963961

964962
###############################################################################
965963
# Replay buffer storage and batch size
966-
# ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
964+
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
967965
#
968966
# TorchRL replay buffer counts the number of elements along the first dimension.
969967
# Since we'll be feeding trajectories to our buffer, we need to adapt the buffer
@@ -1051,7 +1049,7 @@ def ceil_div(x, y):
10511049
# estimates.
10521050
#
10531051
# Target network updater
1054-
# ^^^^^^^^^^^^^^^^^^^^^^
1052+
# ~~~~~~~~~~~~~~~~~~~~~~
10551053
#
10561054
# Target networks are a crucial part of off-policy RL algorithms.
10571055
# Updating the target network parameters is made easy thanks to the

tutorials/sphinx-tutorials/coding_ppo.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
frame_skip = 1
173173
frames_per_batch = 1000 // frame_skip
174174
# For a complete training, bring the number of frames up to 1M
175-
total_frames = 50_000 // frame_skip
175+
total_frames = 10_000 // frame_skip
176176

177177
######################################################################
178178
# PPO parameters

tutorials/sphinx-tutorials/dqn_with_rnn.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -394,11 +394,12 @@
394394
######################################################################
395395
# Let's plot our results:
396396
#
397-
from matplotlib import pyplot as plt
397+
if traj_lens:
398+
from matplotlib import pyplot as plt
398399

399-
plt.plot(traj_lens)
400-
plt.xlabel("Test collection")
401-
plt.title("Test trajectory lengths")
400+
plt.plot(traj_lens)
401+
plt.xlabel("Test collection")
402+
plt.title("Test trajectory lengths")
402403

403404
######################################################################
404405
# Conclusion

tutorials/sphinx-tutorials/pendulum.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@
139139
# 0 too.
140140
#
141141
# Coding the effect of an action: :func:`~torchrl.envs.EnvBase._step`
142-
# ------------------------------------------------------------------
142+
# -------------------------------------------------------------------
143143
#
144144
# The step method is the first thing to consider, as it will encode
145145
# the simulation that is of interest to us. In TorchRL, the
@@ -263,7 +263,7 @@ def angle_normalize(x):
263263

264264
######################################################################
265265
# Resetting the simulator: :func:`~torchrl.envs.EnvBase._reset`
266-
# ------------------------------------------------------------
266+
# -------------------------------------------------------------
267267
#
268268
# The second method we need to care about is the
269269
# :meth:`~torchrl.envs.EnvBase._reset` method. Like
@@ -464,7 +464,7 @@ def _set_seed(self, seed: Optional[int]):
464464

465465
######################################################################
466466
# Wrapping things together: the :class:`~torchrl.envs.EnvBase` class
467-
# -----------------------------------------------------------------
467+
# ------------------------------------------------------------------
468468
#
469469
# We can finally put together the pieces and design our environment class.
470470
# The specs initialization needs to be performed during the environment

0 commit comments

Comments
 (0)