Closed RylanSchaeffer closed 4 years ago
I can reproduce this locally on CPU.
I found a short-term workaround by adding the following code to <agent>/run_atari.py
and it works fine, which suggests to me the problem is not caused by a failure to flush some buffer.
with open(FLAGS.results_csv_path, 'a') as fp:
results_dict = collections.OrderedDict((n, v) for n, v, _ in log_output)
if state.iteration == 0:
fp.write(','.join(list(results_dict.keys())))
fp.write('\n')
fp.write(','.join(list(map(str, results_dict.values()))))
fp.write('\n')
At first glance, I think it's because in the CsvWriter we open the file once and only close it at the very end (not after each logging step), so nothing gets written to disk until then. In your fix, you are re-opening the file whenever you want to append a row, and close it again (implicitly via the context manager).
This should be an easy fix, will update soon.
I didn't know that data is only flushed to the file once the file reference is closed. But yes, your summary of what I'm doing is correct and what you propose sounds good!
@GeorgOstrovski any updates?
This should be resolved by this commit. The CsvWriter is now nearly stateless, a file is being opened & closed for each write.
Wonderful. @GeorgOstrovski , I have a quick question - for researching distributional RL algorithms based on DQN and Atari environments, what are the comparative advantages of this codebase and dopamine?
I have to admit I haven't worked with dopamine's more recent JAX-based DQN implementations, so take with a grain of salt.
In the DQN Zoo we have put a particular emphasis on faithfully reproducing published algorithms (e.g. included all elements like NoisyNets in Rainbow, made sure to use all the same hyperparameter settings, etc) and strived for research friendliness via simplicity - all agent code explicit, contained in 1-2 files, easily modifiable.
These are in my view the biggest arguments in favour of the dqn_zoo, but not necessarily against dopamine (it's also easy to work with!) - I think ultimately it really comes down to personal preference.
My concern with both of these is how supported they'll be moving forward. Dopamine seems written entirely by one engineer, which is typically a warning. What about this project?
As stated in README.md / CONTRIBUTING, we consider this release a stable snapshot of historic DQN-based agents, and do not foresee any substantial changes beyond bug fixes. If by support you mean more than that - i.e. further development, adding new features, etc - we do not intend to evolve this code base in that sense. Continuing independent development on a fork is of course a possible avenue for those interested in a further evolution of this codebase.
What about adding more historic DQN-based agents? e.g. expectile regression, hyperbolic discounting, etc. (https://arxiv.org/abs/1902.06865)
I wouldn't view that as further development or adding new features, hence why I'm asking.
To re-iterate a reply from a previous thread:
We’re grateful for these suggestions and will consider them case-by-case. In this instance it is an explicit non-goal to incorporate as many DQN variants as we can. [...] being selective means that we can provide evaluation data on all 57 games. [...]
Please see also README.md and CONTRIBUTING for further details.
Side note: I think this discussion has exceeded the scope of the original question about the CsvWriter substantially ;)
When you run an agent-env-seed combination, either using the Docker image or straight Python, no results are written to disk in the
results.csv
output file. I let the code run overnight on my cluster and nothing was flushed to the CSV. This was the output to stdout:and so on. But the
results.csv
file was created and remains empty.