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

Environment crash during training #87

Closed
gy2256 opened this issue Feb 25, 2017 · 3 comments
Closed

Environment crash during training #87

gy2256 opened this issue Feb 25, 2017 · 3 comments

Comments

@gy2256
Copy link

gy2256 commented Feb 25, 2017

Hello,

I am trying to use CEM algorithm to train Lunar Lander - V2. Here is my script:

from rllab.algos.cem import CEM
from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline
from rllab.envs.gym_env import GymEnv
from rllab.envs.normalized_env import normalize
from rllab.misc.instrument import run_experiment_lite
from rllab.policies.categorical_mlp_policy import CategoricalMLPPolicy


def run_task(*_):
    env = GymEnv("LunarLander-v2")

    policy = CategoricalMLPPolicy(
        env_spec=env.spec,
    
        hidden_sizes=(32, 32)
    )

    baseline = LinearFeatureBaseline(env_spec=env.spec)



    algo = CEM(
    env=env,
    policy=policy,
    baseline=baseline,
    n_itr=400,
    discount=0.99,
    )
    algo.train()


run_experiment_lite(
    run_task,
    # Number of parallel workers for sampling
    n_parallel=2,
    # Only keep the snapshot parameters for the last iteration
    snapshot_mode="last",
    # Specifies the seed for the experiment. If this is not provided, a random seed
    # will be used
    seed=1,
    # plot=True,
)

And here is the error I have received:

    self._before_reset()
  File "/home/xx/anaconda3/envs/rllab3/lib/python3.5/site-packages/gym/wrappers/monitoring.py", line    190, in _before_reset
    self.stats_recorder.before_reset()
  File "/home/xx/anaconda3/envs/rllab3/lib/python3.5/site-packages/gym/monitoring/stats_recorder.py", line 68, in before_reset
    raise error.Error("Tried to reset environment which is not done. While the monitor is active for {}, you  cannot call reset() unless the episode is over.".format(self.env_id))
gym.error.Error: Tried to reset environment which is not done. While the monitor is active for LunarLander-v2, you cannot call reset() unless the episode is over.
@dementrock
Copy link
Member

Hi @gyang1011, when creating GymEnv, set force_reset to True.

@gy2256
Copy link
Author

gy2256 commented Feb 26, 2017

Hi! After I made the change, the new error appears:

  File "/home/xx/Documents/rllab/rllab/envs/gym_env.py", line 10, in <module>
  monitor_logger.setLevel(logging.WARNING)
NameError: name 'logging' is not defined
[2017-02-25 22:26:09,476] Making new env: LunarLander-v2
 [2017-02-25 22:26:09,677] Creating monitor directory      /home/xx/Documents/rllab/data/local/experiment/experiment_2017_02_25_22_26_08_0001/gym_log
2017-02-25 22:26:10.049284 EST | [experiment_2017_02_25_22_26_08_0001] Populating workers...
Traceback (most recent call last):
    File "/home/xx/Documents/rllab/rllab/envs/gym_env.py", line 10, in <module>
     monitor_logger.setLevel(logging.WARNING)
    Traceback (most recent call last):
     File "/home/xx/Documents/rllab/rllab/envs/gym_env.py", line 10, in <module>
     monitor_logger.setLevel(logging.WARNING)
    NameError: name 'logging' is not defined
    NameError: name 'logging' is not defined
    [2017-02-25 22:26:10,095] Making new env: LunarLander-v2
    [2017-02-25 22:26:10,095] Making new env: LunarLander-v2

@dementrock
Copy link
Member

@gyang1011 can you update to latest rllab?

jonashen pushed a commit to jonashen/rllab that referenced this issue May 29, 2018
When the convenience imports were introduced, they accidentally created
a circular dependency was  between packages.

To avoid future crashes, an analysis of the code imports was performed
to find all the circular dependencies in rllab. We found no no circular
dependencies in the TensorFlow tree, or between packages in the
TensorFlow and Theano tree. There were circulater dependencies in the
Theano tree.

Circular dependencies in the Theano tree are the following:
- The package misc with algos, baselines, core, and viskit.
- The package algos with sampler

Since misc shares so many circular dependencies, conflicting imports
were removed from its file __init__.py.

Regarding algos and sampler, the issue is generated by imports in
sampler in its file __init__.py, so they were removed as well.

Due to these removals, some imports had to be restored to its previous
long package path.
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

2 participants