Skip to content

Commit 1b011fb

Browse files
authored
Make coding_ddpg runnable in CoLab end to end (#2748)
By adding `pip install` cell as well as unhiding `from typing import Tuple`
1 parent d5f2102 commit 1b011fb

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

Diff for: advanced_source/coding_ddpg.py

+8-10
Original file line numberDiff line numberDiff line change
@@ -58,26 +58,24 @@
5858
# Imports and setup
5959
# -----------------
6060
#
61+
# .. code-block:: bash
62+
#
63+
# %%bash
64+
# pip3 install torchrl mujoco glfw
6165

6266
import torchrl
67+
import torch
68+
import tqdm
69+
from typing import Tuple
6370

6471
# sphinx_gallery_start_ignore
6572
import warnings
66-
from typing import Tuple
67-
6873
warnings.filterwarnings("ignore")
6974
# sphinx_gallery_end_ignore
7075

71-
import torch.cuda
72-
import tqdm
73-
74-
import torch.multiprocessing
75-
7676
###############################################################################
7777
# We will execute the policy on CUDA if available
78-
device = (
79-
torch.device("cpu") if torch.cuda.device_count() == 0 else torch.device("cuda:0")
80-
)
78+
device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu")
8179
collector_device = torch.device("cpu") # Change the device to ``cuda`` to use CUDA
8280

8381
###############################################################################

0 commit comments

Comments
 (0)