提交 a0b25827 编写于 作者: W wanghaoshuang

Reuse 'initP2P(bool, std::vector)' in 'initP2P(bool)'

上级 f31bb147
...@@ -108,15 +108,14 @@ void InitP2P(std::vector<int> devices) { ...@@ -108,15 +108,14 @@ void InitP2P(std::vector<int> devices) {
} }
void InitDevices(bool init_p2p) { void InitDevices(bool init_p2p) {
/*Init all available devices by default */ /*Init all available devices by default */
std::vector<platform::Place> places;
places.emplace_back(platform::CPUPlace());
int count = 0;
#ifdef PADDLE_WITH_CUDA #ifdef PADDLE_WITH_CUDA
std::vector<int> devices;
try { try {
count = platform::GetCUDADeviceCount(); int count = platform::GetCUDADeviceCount();
for (int i = 0; i < count; ++i) {
devices.push_back(i);
}
} catch (const std::exception &exp) { } catch (const std::exception &exp) {
LOG(WARNING) << "Compiled with WITH_GPU, but no GPU found in runtime."; LOG(WARNING) << "Compiled with WITH_GPU, but no GPU found in runtime.";
} }
...@@ -124,14 +123,7 @@ void InitDevices(bool init_p2p) { ...@@ -124,14 +123,7 @@ void InitDevices(bool init_p2p) {
LOG(WARNING) LOG(WARNING)
<< "'CUDA' is not supported, Please re-compile with WITH_GPU option"; << "'CUDA' is not supported, Please re-compile with WITH_GPU option";
#endif #endif
InitDevices(init_p2p, devices);
for (int i = 0; i < count; ++i) {
places.emplace_back(platform::CUDAPlace(i));
}
if (init_p2p) {
InitP2P(count);
}
platform::DeviceContextPool::Init(places);
} }
void InitDevices(bool init_p2p, const std::vector<int> devices) { void InitDevices(bool init_p2p, const std::vector<int> devices) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册