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

Tensorboard logging does not work in TF2 branch #1033

Open
lerad opened this issue Nov 8, 2019 · 4 comments
Open

Tensorboard logging does not work in TF2 branch #1033

lerad opened this issue Nov 8, 2019 · 4 comments
Labels

Comments

@lerad
Copy link

lerad commented Nov 8, 2019

I got an error, when trying to log tensorboard output in the TF2 branch:

set OPENAI_LOG_FORMAT=stdout,log,csv,tensorboard
python -m baselines.run --alg=ppo2 --env=CartPole-v0 --network=mlp --save_path model --log_path log/ --num_timesteps=30000 --nsteps=128

The following exception occured:

File "[..]\lib\site-packages\baselines\run.py", line 249, in
main(sys.argv)
File "[..]\lib\site-packages\baselines\run.py", line 209, in main
model, env = train(args, extra_args)
File "[..]\lib\site-packages\baselines\run.py", line 79, in train
**alg_kwargs
File "[..]\lib\site-packages\baselines\ppo2\ppo2.py", line 193, in learn
logger.dumpkvs()
File "[..]\lib\site-packages\baselines\logger.py", line 219, in dumpkvs
return get_current().dumpkvs()
File "[..]\lib\site-packages\baselines\logger.py", line 333, in dumpkvs
fmt.writekvs(d)
File "[..]\lib\site-packages\baselines\logger.py", line 163, in writekvs
summary = self.tf.Summary(value=[summary_val(k, v) for k, v in kvs.items()])
AttributeError: module 'tensorflow' has no attribute 'Summary'

I used a virtualenv with only tensorflow==2.0.0, tensorflow-gpu=2.0.0, baselines version
(commit 713f1a0) and python 3.6.7.

@christopherhesse
Copy link
Contributor

@tanzhenyu

@manavchoudhary
Copy link

@tanzhenyu , @christopherhesse, @pzhokhov
I too get an error when trying to use tensorboard log format to train PPO2, in the 'tf2' branch:
Command :

OPENAI_LOGDIR=./boxing_log OPENAI_LOG_FORMAT=tensorboard python -m baselines.run --alg=ppo2 --env=BoxingNoFrameskip-v4 --num_timesteps=1e7 --nsteps=128

I got the following error :

Traceback (most recent call last):
File "[..]/anaconda3/envs/extar/lib/python3.7/runpy.py", line 193, in _run_module_as_main
"main", mod_spec)
File "[..]/anaconda3/envs/extar/lib/python3.7/runpy.py", line 85, in _run_code
exec(code, run_globals)
File "[..]/baselines/baselines/run.py", line 250, in
main(sys.argv)
File "[..]/baselines/baselines/run.py", line 211, in main
configure_logger(args.log_path)
File "[..]/baselines/baselines/run.py", line 199, in configure_logger
logger.configure(**kwargs)
File "[..]/baselines/baselines/logger.py", line 395, in configure
output_formats = [make_output_format(f, dir, log_suffix) for f in format_strs]
File "[..]/baselines/baselines/logger.py", line 395, in
output_formats = [make_output_format(f, dir, log_suffix) for f in format_strs]
File "[..]/baselines/baselines/logger.py", line 185, in make_output_format
return TensorBoardOutputFormat(osp.join(ev_dir, 'tb%s' % log_suffix))
File "[..]/baselines/baselines/logger.py", line 156, in init
self.writer = pywrap_tensorflow.EventsWriter(compat.as_bytes(path))
AttributeError: module 'tensorflow.python.pywrap_tensorflow' has no attribute 'EventsWriter'

I am using tensorflow==2.2.0, gym==0.15.7, baselines commit #1032, Python 3.7.6

My understanding of the above error is that, the tensorboard summary writing code in the 'baselines/common/logger.py' of the tf2 branch, has not been properly adapted for TF2.0.
Also, before the above error I got another error regarding 'FlattenDictWrapper' but I fixed that using #1051

Thanks a lot for your help.

@xpz234
Copy link

xpz234 commented Apr 10, 2021

AttributeError: module 'tensorflow.python.pywrap_tensorflow' has no attribute 'EventsWriter'

@manavchoudhary
Do you have any way to solve this problem?

@omsrisagar
Copy link

omsrisagar commented Nov 16, 2021

@xpz234

I solved this error with the following:

from tensorflow.python.client import _pywrap_events_writer
self.writer = _pywrap_events_writer.EventsWriter(compat.as_bytes(path))

This is the source I used for obtaining this fix:
https://github.com/tensorflow/tensorflow/blob/87462bfac761435a46641ff2f10ad0b6e5414a4b/tensorflow/python/client/events_writer_test.py

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants