From cb72a7361cd0ca4c1d40c53e536df1bd67b0f936 Mon Sep 17 00:00:00 2001 From: littletomatodonkey Date: Thu, 6 Aug 2020 11:34:15 +0000 Subject: [PATCH] fix visualdl version bug --- docs/en/faq_en.md | 5 +++++ docs/zh_CN/faq.md | 5 +++++ tools/train.py | 13 +++++++++---- tools/train_multi_platform.py | 13 +++++++++---- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/docs/en/faq_en.md b/docs/en/faq_en.md index 70d73e65..e006870b 100644 --- a/docs/en/faq_en.md +++ b/docs/en/faq_en.md @@ -46,3 +46,8 @@ VALID: >> * Q: What should I do if I want to transform the weights' format from `pdparams` to an earlier version(before Paddle1.7.0), which consists of the scattered files? * A: You can use `fluid.load` to load the `pdparams` weights and use `fluid.io.save_vars` to save the weights as scattered files. + + +>> +* Q: The error occured when using visualdl under python2, shows that: `TypeError: __init__() missing 1 required positional argument: 'sync_cycle'`. +* A: `Visualdl` is only supported on python3 as now, whose version needs also be higher than `2.0`. If your visualdl version is lower than 2.0, you can also install visualdl 2.0 by `pip3 install visualdl==2.0.0b8 -i https://mirror.baidu.com/pypi/simple`. diff --git a/docs/zh_CN/faq.md b/docs/zh_CN/faq.md index ca79b1e6..dd73b674 100644 --- a/docs/zh_CN/faq.md +++ b/docs/zh_CN/faq.md @@ -46,3 +46,8 @@ VALID: >> * Q: 如果想将保存的`pdparams`模型参数文件转换为早期版本(Paddle1.7.0之前)的零碎文件(每个文件均为一个单独的模型参数),该怎么实现呢? * A: 可以首先导入`pdparams`模型,之后使用`fluid.io.save_vars`函数将模型保存为零散的碎文件。 + + +>> +* Q: python2下,使用visualdl的时候,报出以下错误,`TypeError: __init__() missing 1 required positional argument: 'sync_cycle'`,这是为什么呢? +* A: 目前visualdl仅支持在python3下运行,visualdl需要是2.0以上的版本,如果visualdl版本不对的话,可以通过以下方式进行安装:`pip3 install visualdl==2.0.0b8 -i https://mirror.baidu.com/pypi/simple`cd diff --git a/tools/train.py b/tools/train.py index e9188eb0..43c399fa 100644 --- a/tools/train.py +++ b/tools/train.py @@ -18,6 +18,7 @@ from __future__ import print_function import argparse import os +from sys import version_info import paddle.fluid as fluid from paddle.fluid.incubate.fleet.base import role_maker @@ -101,11 +102,15 @@ def main(args): compiled_train_prog = fleet.main_program + vdl_writer = None if args.vdl_dir: - from visualdl import LogWriter - vdl_writer = LogWriter(args.vdl_dir) - else: - vdl_writer = None + if version_info.major == 2: + logger.info( + "visualdl is just supported for python3, so it is disabled in python2..." + ) + else: + from visualdl import LogWriter + vdl_writer = LogWriter(args.vdl_dir) for epoch_id in range(config.epochs): # 1. train with train dataset diff --git a/tools/train_multi_platform.py b/tools/train_multi_platform.py index 1583a98c..0b1ea2c1 100644 --- a/tools/train_multi_platform.py +++ b/tools/train_multi_platform.py @@ -18,6 +18,7 @@ from __future__ import print_function import argparse import os +from sys import version_info import paddle.fluid as fluid @@ -110,11 +111,15 @@ def main(args): compiled_valid_prog = program.compile( config, valid_prog, share_prog=compiled_train_prog) + vdl_writer = None if args.vdl_dir: - from visualdl import LogWriter - vdl_writer = LogWriter(args.vdl_dir) - else: - vdl_writer = None + if version_info.major == 2: + logger.info( + "visualdl is just supported for python3, so it is disabled in python2..." + ) + else: + from visualdl import LogWriter + vdl_writer = LogWriter(args.vdl_dir) for epoch_id in range(config.epochs): # 1. train with train dataset -- GitLab