You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`"""Example of training a policy from exp-x config with OmniSafe."""
import warnings
import torch
from omnisafe.common.experiment_grid import ExperimentGrid
from omnisafe.utils.exp_grid_tools import train
if name == 'main':
eg = ExperimentGrid(exp_name='TEST')
# set up the algorithms.
naive_lagrange_policy = ['PPOLag']
first_order_policy = [
'P3O',
#'CUP',
#'FOCOPS',
]
second_order_policy = ['PCPO',
'RCPO']
saute_policy = ['PPOSaute']
simmer_policy = ['CRPO']
early_mdp_policy = ['PPOEarlyTerminated']
eg.add(
'algo',
naive_lagrange_policy
+
first_order_policy
+
second_order_policy
+
saute_policy
+
simmer_policy
+
early_mdp_policy
)
# you can use wandb to monitor the experiment.
eg.add('logger_cfgs:use_wandb', [False])
# you can use tensorboard to monitor the experiment.
eg.add('logger_cfgs:use_tensorboard', [True])
# the default configs here are as follows:
# eg.add('algo_cfgs:steps_per_epoch', [20000])
# eg.add('train_cfgs:total_steps', [20000 * 500])
# which can reproduce results of 1e7 steps.
# if you want to reproduce results of 1e6 steps, using
# eg.add('algo_cfgs:steps_per_epoch', [2048])
# eg.add('train_cfgs:total_steps', [2048 * 500])
# set the device.
avaliable_gpus = list(range(torch.cuda.device_count()))
# if you want to use GPU, please set gpu_id like follows:
# gpu_id = [0, 1, 2, 3]
# if you want to use CPU, please set gpu_id = None
# we recommends using CPU to obtain results as consistent
# as possible with our publicly available results,
# since the performance of all on-policy algorithms
# in OmniSafe is tested on CPU.
gpu_id = [0,1,2,3]
if gpu_id and not set(gpu_id).issubset(avaliable_gpus):
warnings.warn('The GPU ID is not available, use CPU instead.', stacklevel=1)
gpu_id = None
# set up the environment.
eg.add('env_id', [
#'SafetyCarGoal2-v0',#1
#'SafetyRacecarCircle2-v0',#2
'SafetyHopperVelocity-v1',
#'SafetyCarButton2-v0',#3
'SafetyAntVelocity-v1',
'SafetyHalfCheetahVelocity-v1',#4
#'SafetyPointGoal1-v0',
#'SafetyPointButton1-v0',
#'SafetyCarCircle1-v0',
#'SafetyCarButton1-v0',
'SafetyHumanoidVelocity-v1',#5
#'SafetyCarGoal1-v0'#6
])
eg.add('seed', [0,5,10])#1,5,10,15,20
#eg.add('seed', [8])
# total experiment num must can be divided by num_pool.
# meanwhile, users should decide this value according to their machine.
eg.run(train, num_pool=3, gpu_id=gpu_id)`
Thank you for your work! Hello, I would like to ask a question about why I use CPU instead of GPU when running this code?
The text was updated successfully, but these errors were encountered:
Required prerequisites
Questions
`"""Example of training a policy from exp-x config with OmniSafe."""
import warnings
import torch
from omnisafe.common.experiment_grid import ExperimentGrid
from omnisafe.utils.exp_grid_tools import train
if name == 'main':
eg = ExperimentGrid(exp_name='TEST')
The text was updated successfully, but these errors were encountered: