win10下打开tensorboard报错:ValueError: Invalid format string

1. 解决错误:

利用anaconda创建新环境,并成功安装上了TensorFlow,可是当用tensorboard查看events的时候还是报错了:

Traceback (most recent call last):
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\runpy.py", line 193, in _run_module_as_main
    "__main__", mod_spec)
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\runpy.py", line 85, in _run_code
    exec(code, run_globals)
  File "C:\ProgramData\Anaconda3\envs\tensorflow-gpu\Scripts\tensorboard.exe\__main__.py", line 9, in 
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorboard\main.py", line 57, in run_main
    app.run(tensorboard.main, flags_parser=tensorboard.configure)
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\site-packages\absl\app.py", line 300, in run
    _run_main(main, args)
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\site-packages\absl\app.py", line 251, in _run_main
    sys.exit(main(argv))
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorboard\program.py", line 228, in main
    self._register_info(server)
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorboard\program.py", line 274, in _register_info
    manager.write_info_file(info)
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorboard\manager.py", line 268, in write_info_file
    payload = "%s\n" % _info_to_string(tensorboard_info)
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorboard\manager.py", line 128, in _info_to_string
    for k in _TENSORBOARD_INFO_FIELDS
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorboard\manager.py", line 128, in 
    for k in _TENSORBOARD_INFO_FIELDS
  File "c:\programdata\anaconda3\envs\tensorflow-gpu\lib\site-packages\tensorboard\manager.py", line 50, in 
    serialize=lambda dt: int(dt.strftime("%s")),
ValueError: Invalid format string

看到了一个帖子:

https://stackoverflow.com/questions/54814113/invalid-format-string-tensorboard

里面提到打开TensorFlow安装的位置找到里面的:lib\site-packages\tensorboard\manager.py(我的完整路径是C:\ProgramData\Anaconda3\envs\tensorflow-gpu\Lib\site-packages\tensorboard\manager.py)

找到里面第50行:

serialize=lambda dt: int(dt.strftime("%s")),

再将小s改成大S就OK了

保存后再运行tensorboard发现不报错了

 

2. 运行tensorboard

tensorboard --logdir=路径

 

3. 修改host

在Windows的路径:C:\Windows\System32\drivers\etc下打开hosts文件

将里面的20行的注释删掉

如果国内网上不去TensorFlow官网,可以在最后加上一句:

64.233.188.121 www.tensorflow.org

 

4. 打开浏览器,输入网址:

http://localhost:6006

搞定!

你可能感兴趣的:(日用小技能)