提交 e1999538 编写于 作者: D dzhwinter

debug the device context

上级 372caf40
......@@ -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)
......
......@@ -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
......
......@@ -94,7 +94,9 @@ void InitDevices(bool init_p2p, const std::vector<int> 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<int> 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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册