提交 a4b452a2 编写于 作者: W wanghaoshuang

Remove initP2P(bool) and init function in framework.

上级 e4708565
......@@ -15,7 +15,6 @@ limitations under the License. */
#include <algorithm>
#include <stdexcept>
#include <string>
#include <vector>
#include "paddle/fluid/framework/init.h"
#include "paddle/fluid/framework/operator.h"
......@@ -26,26 +25,9 @@ limitations under the License. */
namespace paddle {
namespace framework {
DEFINE_string(devices, "", "The devices to be used.");
DEFINE_bool(init_p2p, true, "Whether to init p2p.");
std::once_flag gflags_init_flag;
std::once_flag p2p_init_flag;
using paddle::platform::DeviceContextPool;
void Init(std::vector<std::string> argv) {
InitGflags(argv);
// init devices
std::vector<int> devices;
std::string token;
std::istringstream tokenStream(FLAGS_devices);
while (std::getline(tokenStream, token, ',')) {
devices.push_back(std::stoi(token));
}
InitDevices(FLAGS_init_p2p, devices);
}
void InitGflags(std::vector<std::string> argv) {
std::call_once(gflags_init_flag, [&]() {
argv.push_back("dummy");
......@@ -62,27 +44,6 @@ void InitGflags(std::vector<std::string> argv) {
});
}
void InitP2P(int count) {
#ifdef PADDLE_WITH_CUDA
std::call_once(p2p_init_flag, [&]() {
for (int i = 0; i < count; ++i) {
for (int j = 0; j < count; ++j) {
if (i == j) continue;
int can_acess = -1;
PADDLE_ENFORCE(cudaDeviceCanAccessPeer(&can_acess, i, j),
"Failed to test P2P access.");
if (can_acess != 1) {
LOG(WARNING) << "Cannot enable P2P access from " << i << " to " << j;
} else {
cudaSetDevice(i);
cudaDeviceEnablePeerAccess(j, 0);
}
}
}
});
#endif
}
void InitP2P(std::vector<int> devices) {
#ifdef PADDLE_WITH_CUDA
std::call_once(p2p_init_flag, [&]() {
......
......@@ -22,8 +22,6 @@ limitations under the License. */
namespace paddle {
namespace framework {
void Init(std::vector<std::string> argv);
void InitGflags(std::vector<std::string> argv);
void InitGLOG(const std::string &prog_name);
......
......@@ -16,15 +16,29 @@ limitations under the License. */
#include <algorithm>
#include <fstream>
#include <vector>
#include "paddle/fluid/framework/block_desc.h"
#include "paddle/fluid/framework/feed_fetch_type.h"
#include "paddle/fluid/framework/op_registry.h"
#include "paddle/fluid/pybind/pybind.h"
DEFINE_string(devices, "", "The devices to be used.");
DEFINE_bool(init_p2p, true, "Whether to init p2p.");
namespace paddle {
namespace inference {
void Init(const std::vector<std::string> argv) { framework::Init(argv); }
void Init(const std::vector<std::string> argv) {
framework::InitGflags(argv);
// init devices
std::vector<int> devices;
std::string token;
std::istringstream tokenStream(FLAGS_devices);
while (std::getline(tokenStream, token, ',')) {
devices.push_back(std::stoi(token));
}
framework::InitDevices(FLAGS_init_p2p, devices);
}
void ReadBinaryFile(const std::string& filename, std::string* contents) {
std::ifstream fin(filename, std::ios::in | std::ios::binary);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册