From 059096741e85d8595b1d6767de936afb051d7f06 Mon Sep 17 00:00:00 2001 From: Yang Yu Date: Wed, 3 Jan 2018 16:09:30 +0800 Subject: [PATCH] Add init glog --- paddle/framework/init.cc | 4 ++++ paddle/framework/init.h | 2 ++ paddle/pybind/pybind.cc | 1 + python/paddle/v2/fluid/__init__.py | 25 +++++++++++++------------ 4 files changed, 20 insertions(+), 12 deletions(-) diff --git a/paddle/framework/init.cc b/paddle/framework/init.cc index 682cff168d4..19800233725 100644 --- a/paddle/framework/init.cc +++ b/paddle/framework/init.cc @@ -75,5 +75,9 @@ bool InitDevices(const std::vector &devices) { return true; } +void InitGLOG(const std::string &prog_name) { + google::InitGoogleLogging(prog_name.c_str()); +} + } // namespace framework } // namespace paddle diff --git a/paddle/framework/init.h b/paddle/framework/init.h index 33907f9eb00..9c84a03ded5 100644 --- a/paddle/framework/init.h +++ b/paddle/framework/init.h @@ -22,6 +22,8 @@ namespace framework { void InitGflags(std::vector &argv); +void InitGLOG(const std::string &prog_name); + bool InitDevices(const std::vector &devices); } // namespace framework diff --git a/paddle/pybind/pybind.cc b/paddle/pybind/pybind.cc index 04485ce7c1a..364db62cba6 100644 --- a/paddle/pybind/pybind.cc +++ b/paddle/pybind/pybind.cc @@ -427,6 +427,7 @@ All parameter, weight, gradient are variables in Paddle. m.def("unique_integer", UniqueIntegerGenerator); m.def("init_gflags", framework::InitGflags); + m.def("init_glog", framework::InitGLOG); m.def("init_devices", &framework::InitDevices); m.def("is_compile_gpu", IsCompileGPU); diff --git a/python/paddle/v2/fluid/__init__.py b/python/paddle/v2/fluid/__init__.py index 225b41c5043..b00892d91a0 100644 --- a/python/paddle/v2/fluid/__init__.py +++ b/python/paddle/v2/fluid/__init__.py @@ -1,23 +1,23 @@ # import all class inside framework into fluid module -import framework -from framework import * -# import all class inside executor into fluid module -import executor -from executor import * +from core import LoDTensor -import io +import backward +import clip import evaluator +# import all class inside executor into fluid module +import executor +import framework import initializer +import io import layers import nets import optimizer -import backward import regularizer -from param_attr import ParamAttr from data_feeder import DataFeeder -from core import LoDTensor, CPUPlace, CUDAPlace from distribute_transpiler import DistributeTranspiler -import clip +from executor import * +from framework import * +from param_attr import ParamAttr Tensor = LoDTensor __all__ = framework.__all__ + executor.__all__ + [ @@ -27,7 +27,7 @@ __all__ = framework.__all__ + executor.__all__ + [ ] -def __read_gflags_from_env__(): +def __bootstrap__(): """ Enable reading gflags from environment variables. @@ -41,6 +41,7 @@ def __read_gflags_from_env__(): read_env_flags.append('fraction_of_gpu_memory_to_use') core.init_gflags([sys.argv[0]] + ["--tryfromenv=" + ",".join(read_env_flags)]) + core.init_glog(sys.argv[0]) if core.is_compile_gpu(): core.init_devices(["CPU", "GPU:0"]) @@ -48,4 +49,4 @@ def __read_gflags_from_env__(): core.init_devices(["CPU"]) -__read_gflags_from_env__() +__bootstrap__() -- GitLab