Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion sota-implementations/a2c/a2c_atari.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,12 @@ def main(cfg: DictConfig): # noqa: F821

device = cfg.loss.device
if not device:
device = torch.device("cpu" if not torch.cuda.is_available() else "cuda:0")
if torch.cuda.is_available():
device = torch.device("cuda:0")
elif torch.npu.is_available():
device = torch.device("npu:0")
else:
device = torch.device("cpu")
else:
device = torch.device(device)

Expand Down
7 changes: 6 additions & 1 deletion sota-implementations/a2c/a2c_mujoco.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@ def main(cfg: DictConfig): # noqa: F821

device = cfg.loss.device
if not device:
device = torch.device("cpu" if not torch.cuda.is_available() else "cuda:0")
if torch.cuda.is_available():
device = torch.device("cuda:0")
elif torch.npu.is_available():
device = torch.device("npu:0")
else:
device = torch.device("cpu")
else:
device = torch.device(device)

Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/cql/cql_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/cql/cql_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
7 changes: 6 additions & 1 deletion sota-implementations/cql/discrete_cql_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,12 @@
def main(cfg): # noqa: F821
device = cfg.optim.device
if device in ("", None):
device = "cuda:0" if torch.cuda.is_available() else "cpu"
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)

# Create logger
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/cql/discrete_cql_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/crossq/crossq.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = torch.device("cuda:0")
elif torch.npu.is_available():
device = torch.device("npu:0")
else:
device = torch.device("cpu")
device = torch.device(device)
Expand Down
4 changes: 4 additions & 0 deletions sota-implementations/ddpg/ddpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand All @@ -51,6 +53,8 @@ def main(cfg: DictConfig): # noqa: F821
if collector_device in ("", None):
if torch.cuda.is_available():
collector_device = "cuda:0"
elif torch.npu.is_available():
collector_device = "npu:0"
else:
collector_device = "cpu"
collector_device = torch.device(collector_device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/decision_transformer/dt.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def main(cfg: DictConfig): # noqa: F821
if model_device in ("", None):
if torch.cuda.is_available():
model_device = "cuda:0"
elif torch.npu.is_available():
model_device = "npu:0"
else:
model_device = "cpu"
model_device = torch.device(model_device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/decision_transformer/online_dt.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ def main(cfg: DictConfig): # noqa: F821
if model_device in ("", None):
if torch.cuda.is_available():
model_device = "cuda:0"
elif torch.npu.is_available():
model_device = "npu:0"
else:
model_device = "cpu"
model_device = torch.device(model_device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/dqn/dqn_atari.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/dqn/dqn_cartpole.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/gail/gail.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/iql/discrete_iql.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
4 changes: 3 additions & 1 deletion sota-implementations/iql/iql_offline.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,13 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)

# Creante env
# Create env
train_env, eval_env = make_environment(
cfg,
cfg.logger.eval_envs,
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/iql/iql_online.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/ppo/ppo_atari.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/ppo/ppo_mujoco.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/sac/sac-async.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = torch.device("cuda:0")
elif torch.npu.is_available():
device = torch.device("npu:0")
else:
device = torch.device("cpu")
device = torch.device(device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/sac/sac.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = torch.device("cuda:0")
elif torch.npu.is_available():
device = torch.device("npu:0")
else:
device = torch.device("cpu")
device = torch.device(device)
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/td3/td3.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = torch.device("cuda:0")
elif torch.npu.is_available():
device = torch.device("npu:0")
else:
device = torch.device("cpu")
else:
Expand Down
2 changes: 2 additions & 0 deletions sota-implementations/td3_bc/td3_bc.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ def main(cfg: DictConfig): # noqa: F821
if device in ("", None):
if torch.cuda.is_available():
device = "cuda:0"
elif torch.npu.is_available():
device = "npu:0"
else:
device = "cpu"
device = torch.device(device)
Expand Down
Loading