diff --git a/cmake/external/gflags.cmake b/cmake/external/gflags.cmake index d9aa10c532146072508fd0dc036ac8927dba933e..0d4cecd4de75aaafeae66c1dda1d96d527b02171 100644 --- a/cmake/external/gflags.cmake +++ b/cmake/external/gflags.cmake @@ -47,6 +47,10 @@ ExternalProject_Add( -DCMAKE_POSITION_INDEPENDENT_CODE:BOOL=ON -DCMAKE_BUILD_TYPE:STRING=${THIRD_PARTY_BUILD_TYPE} ) + +ADD_LIBRARY(gflags STATIC IMPORTED GLOBAL) +SET_PROPERTY(TARGET gflags PROPERTY IMPORTED_LOCATION ${GFLAGS_LIBRARIES}) +ADD_DEPENDENCIES(gflags extern_gflags) IF(WIN32) IF(NOT EXISTS "${GFLAGS_INSTALL_DIR}/lib/libgflags.lib") add_custom_command(TARGET extern_gflags POST_BUILD @@ -54,9 +58,6 @@ IF(WIN32) ) ENDIF() ENDIF(WIN32) -ADD_LIBRARY(gflags STATIC IMPORTED GLOBAL) -SET_PROPERTY(TARGET gflags PROPERTY IMPORTED_LOCATION ${GFLAGS_LIBRARIES}) -ADD_DEPENDENCIES(gflags extern_gflags) LIST(APPEND external_project_dependencies gflags) diff --git a/paddle/fluid/inference/api/api_impl.cc b/paddle/fluid/inference/api/api_impl.cc index f0ea482994d53c26c546c2acccf99ce72d5201ff..2dae4338810c84e689c6956efb9269b8a9a133df 100644 --- a/paddle/fluid/inference/api/api_impl.cc +++ b/paddle/fluid/inference/api/api_impl.cc @@ -61,7 +61,7 @@ bool NativePaddlePredictor::Init( platform::EnableProfiler(tracking_device); } #endif - + VLOG(3) << "before Place"; if (config_.use_gpu) { place_ = paddle::platform::CUDAPlace(config_.device); } else { @@ -73,10 +73,12 @@ bool NativePaddlePredictor::Init( sub_scope_ = &(parent_scope->NewScope()); PADDLE_ENFORCE_NOT_NULL(sub_scope_, "create sub scope fail"); } else { + VLOG(3) << "Before InitDevices"; paddle::framework::InitDevices(false); + VLOG(3) << "after InitDevices"; scope_.reset(new paddle::framework::Scope()); } - VLOG(3) << "after scope" + VLOG(3) << "after scope"; executor_.reset(new paddle::framework::Executor(place_)); VLOG(3) << "executor"; // Initialize the inference program diff --git a/paddle/fluid/platform/init.cc b/paddle/fluid/platform/init.cc index 2a7bf87d10858d6737ccdeb6b489e90e20c90b4b..7b957378a7ce69d079c03b76c1cb99010fb69f5d 100644 --- a/paddle/fluid/platform/init.cc +++ b/paddle/fluid/platform/init.cc @@ -94,7 +94,9 @@ void InitDevices(bool init_p2p, const std::vector devices) { int count = 0; #ifdef PADDLE_WITH_CUDA try { + VLOG(3) << "get cuda count"; count = platform::GetCUDADeviceCount(); + VLOG(3) << "get cuda pass"; } catch (const std::exception &exp) { LOG(WARNING) << "Compiled with WITH_GPU, but no GPU found in runtime."; } @@ -107,11 +109,14 @@ void InitDevices(bool init_p2p, const std::vector devices) { } places.emplace_back(platform::CUDAPlace(devices[i])); } + VLOG(3) << "before p2p"; if (init_p2p) { InitP2P(devices); } + VLOG(3) << "p2p pass"; places.emplace_back(platform::CPUPlace()); platform::DeviceContextPool::Init(places); + VLOG(3) << "init pass"; #ifndef PADDLE_WITH_MKLDNN platform::SetNumThreads(FLAGS_paddle_num_threads); #endif