diff --git a/paddle/framework/init.cc b/paddle/framework/init.cc index 682cff168d4d31e0565fc987604f97a671566fbd..1980023372572a4d058275d9af72eb61f145c1bc 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 33907f9eb00fb3469b53dcf8151557cc7a2d3791..9c84a03ded52632047841f95badbcf44bc9f48d1 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 04485ce7c1ab87f8655b0e6cbaecc36b3382f647..364db62cba6acd7ac380b5017d09f22eefa24813 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 225b41c5043b5792abb90bbad53cbbfce9a3156e..b00892d91a027213527ca879c86b0c1b47b762e9 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__()