diff --git a/advanced_source/coding_ddpg.py b/advanced_source/coding_ddpg.py index 41f02628213..7486b6e0e94 100644 --- a/advanced_source/coding_ddpg.py +++ b/advanced_source/coding_ddpg.py @@ -58,26 +58,24 @@ # Imports and setup # ----------------- # +# .. code-block:: bash +# +# %%bash +# pip3 install torchrl mujoco glfw import torchrl +import torch +import tqdm +from typing import Tuple # sphinx_gallery_start_ignore import warnings -from typing import Tuple - warnings.filterwarnings("ignore") # sphinx_gallery_end_ignore -import torch.cuda -import tqdm - -import torch.multiprocessing - ############################################################################### # We will execute the policy on CUDA if available -device = ( - torch.device("cpu") if torch.cuda.device_count() == 0 else torch.device("cuda:0") -) +device = torch.device("cuda:0" if torch.cuda.is_available() else "cpu") collector_device = torch.device("cpu") # Change the device to ``cuda`` to use CUDA ###############################################################################