Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

launch different seeds simulateously #106

Open
ChenyangRan opened this issue May 14, 2020 · 4 comments
Open

launch different seeds simulateously #106

ChenyangRan opened this issue May 14, 2020 · 4 comments

Comments

@ChenyangRan
Copy link

ChenyangRan commented May 14, 2020

HI, I want to test different seeds for example/sac.py at the same time.
I use the function named run_experiment_here, but the variant['seed'] should be int.
I use a list such as following:

    for seed in seeds:
        run_experiment_here(experiment_function=experiment, variant=variant,
                        exp_id=seed, seed=seed, snapshot_mode='gap', snapshot_gap=10, exp_prefix='HalfCheetahEnv')

The error is

Traceback (most recent call last):
  File "/home/ur/RL_code/torch/rlkit/examples/il_sac.py", line 124, in <module>
    exp_id=seed, seed=seed, snapshot_mode='gap', snapshot_gap=10, exp_prefix='HalfCheetahEnv'+str(seed))
  File "/home/ur/RL_code/torch/rlkit/rlkit/launchers/launcher_util.py", line 166, in run_experiment_here
    return experiment_function(variant)
  File "/home/ur/RL_code/torch/rlkit/examples/il_sac.py", line 89, in experiment
    algorithm.train()
  File "/home/ur/RL_code/torch/rlkit/rlkit/core/rl_algorithm.py", line 46, in train
    self._train()
  File "/home/ur/RL_code/torch/rlkit/rlkit/core/il_batch_rl_algorithm.py", line 64, in _train
    gt.stamp('evaluation sampling')
  File "/home/ur/anaconda3/envs/rlkit/lib/python3.5/site-packages/gtimer/public/timer.py", line 151, in stamp
    _stamp(name, elapsed, unique, keep_subdivisions, quick_print)
  File "/home/ur/anaconda3/envs/rlkit/lib/python3.5/site-packages/gtimer/public/timer.py", line 698, in _stamp
    _loop_stamp(name, elapsed, unique)
  File "/home/ur/anaconda3/envs/rlkit/lib/python3.5/site-packages/gtimer/public/timer.py", line 714, in _loop_stamp
    _init_loop_stamp(name, unique)
  File "/home/ur/anaconda3/envs/rlkit/lib/python3.5/site-packages/gtimer/public/timer.py", line 725, in _init_loop_stamp
    raise UniqueNameError("Duplicate stamp name (in or at loop): {}".format(name))
gtimer.local.exceptions.UniqueNameError: Duplicate stamp name (in or at loop): evaluation sampling 

Maybe run_experiment can do it, but the same error happens again.

    for exp_id, variant in enumerate(sweeper.iterate_hyperparameters()):
        print('exp_id:{1},variant:{0}'.format(variant, exp_id))
        for seed in seeds:
            run_experiment(
                experiment,
                exp_prefix=exp_prefix,
                mode=mode,
                seed=seed,
                exp_id=exp_id,
                variant=variant,
                use_gpu=True,
                snapshot_gap=100,
                snapshot_mode='gap_and_last', 
            )

I run it by anaconda.

Could you please help me? Or is anyother function can launch different function that can do it?

@kovacgrgur
Copy link

kovacgrgur commented Apr 9, 2021

I believe you can fix this by adding gt.reset_root() at the end of the BatchRLAlgorithm constructor.
Add it at: rlkit/core/batch_rl_algorithm.py line 43 (or in your case il_batch_rl_algorithm.py)

@snasiriany
Copy link
Contributor

I encountered this issue as well, and @kovacgrgur 's solution works! @vitchyr @anair13 would you mind adding this in?

@vitchyr
Copy link
Collaborator

vitchyr commented Sep 9, 2021

Feel free to make a PR and I'll merge it in!

snasiriany added a commit to snasiriany/rlkit that referenced this issue Sep 10, 2021
@snasiriany
Copy link
Contributor

@vitchyr here it is: #142

vitchyr pushed a commit that referenced this issue Sep 10, 2021
fix the issue brought up by #106
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants