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

ValueError: I/O operation on closed file #31

Closed
aravindr93 opened this issue Jul 17, 2016 · 2 comments
Closed

ValueError: I/O operation on closed file #31

aravindr93 opened this issue Jul 17, 2016 · 2 comments

Comments

@aravindr93
Copy link

aravindr93 commented Jul 17, 2016

I'm not sure what I'm doing wrong here. I haven't changed anything from the master branch and the following simple implementation gives me this error. Would appreciate some help. Thanks!

from rllab.baselines.linear_feature_baseline import LinearFeatureBaseline
from rllab.envs.gym_env import GymEnv
from rllab.policies.gaussian_mlp_policy import GaussianMLPPolicy
from rllab.envs.normalized_env import normalize
from rllab.algos.vpg import VPG
import numpy as np

env = normalize(GymEnv("Reacher-v1"))
policy = GaussianMLPPolicy(env_spec=env.spec, hidden_sizes=(16,16))
baseline = LinearFeatureBaseline(env_spec=env.spec)

# set properties
algo.batch_size = 50  # N
algo.max_path_length=50   # T
algo.discount=0.99  # gamma
algo.n_itr=250  # n_iter

algo.train()

I get the following error:

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-5-f78c549ec9f8> in <module>()
----> 1 algo.train()

/home/aravind/Programs/rllab/rllab/algos/batch_polopt.pyc in train(self)
    249             with logger.prefix('itr #%d | ' % itr):
    250                 paths = self.sampler.obtain_samples(itr)
--> 251                 samples_data = self.sampler.process_samples(itr, paths)
    252                 self.log_diagnostics(paths)
    253                 self.optimize_policy(itr, samples_data)

/home/aravind/Programs/rllab/rllab/algos/batch_polopt.pyc in process_samples(self, itr, paths)
    146             )
    147 
--> 148         logger.log("fitting baseline...")
    149         self.algo.baseline.fit(paths)
    150         logger.log("fitted")

/home/aravind/Programs/rllab/rllab/misc/logger.pyc in log(s, with_prefix, with_timestamp)
    112     if not _log_tabular_only:
    113         # Also log to stdout
--> 114         print(out)
    115         for fd in _text_fds.values():
    116             fd.write(out + '\n')

/home/aravind/anaconda2/envs/rllab/lib/python2.7/site-packages/ipykernel/iostream.pyc in write(self, string)
    315 
    316             is_child = (not self._is_master_process())
--> 317             self._buffer.write(string)
    318             if is_child:
    319                 # newlines imply flush in subprocesses

ValueError: I/O operation on closed file
@dementrock
Copy link
Member

Hi @aravindr93, can you try running it outside of IPython and see if it works?

@aravindr93
Copy link
Author

@dementrock It works outside. Not sure what is happening here. Anyway, I'm closing the issue :) Thanks!

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