Skip to content

Commit

Permalink
chore: support num_thread setting (#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaiejj authored Feb 28, 2023
1 parent bb4d71d commit a0a682e
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 2 deletions.
4 changes: 2 additions & 2 deletions omnisafe/algorithms/algo_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ def learn(self):
physical_cores = psutil.cpu_count(logical=False)
use_number_of_threads = bool(self.parallel > physical_cores)

torch.set_num_threads(5)

cfgs = get_default_kwargs_yaml(self.algo, self.env_id, self.algo_type)
exp_name = os.path.join(self.env_id, self.algo)
cfgs.recurisve_update({'exp_name': exp_name, 'env_id': self.env_id})
Expand All @@ -87,6 +85,8 @@ def learn(self):

# check_all_configs(cfgs, self.algo_type)

torch.set_num_threads(cfgs.num_threads)

if distributed.fork(
self.parallel, use_number_of_threads=use_number_of_threads, device=cfgs.device
):
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/CPO.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/CPPOPid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/CUP.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/FOCOPS.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/IPO.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/NaturalPG.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/OnCRPO.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/P3O.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PCPO.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PDO.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PPO.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PPOEarlyTerminated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PPOLag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PPOLagEarlyTerminated.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PPOLagSaute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PPOLagSimmerPid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PPOLagSimmerQ.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PPOSaute.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PPOSimmerPid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PPOSimmerQ.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/PolicyGradient.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/RCPO.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/TRPO.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/TRPOLag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down
2 changes: 2 additions & 0 deletions omnisafe/configs/on-policy/TRPOPid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ defaults:
## -----------------------------Basic configurations for base class PG------------------------ ##
# The random seed
seed: 0
# The number of threads used per experiment
num_threads: 1
# If use tensorboard
use_tensorboard: True
# if use wandb
Expand Down

0 comments on commit a0a682e

Please sign in to comment.