未验证 提交 ce70229b 编写于 作者: G gongweibao 提交者: GitHub

Add max_body_size flags to brpc (#15084)

上级 6f0a1d7b
...@@ -52,12 +52,12 @@ std::unique_ptr<framework::Scope> GenerateVars(platform::Place place) { ...@@ -52,12 +52,12 @@ std::unique_ptr<framework::Scope> GenerateVars(platform::Place place) {
framework::Scope* scope = new framework::Scope(); framework::Scope* scope = new framework::Scope();
framework::Variable* var = scope->Var("var1"); framework::Variable* var = scope->Var("var1");
auto* slr = var->GetMutable<framework::SelectedRows>(); auto* slr = var->GetMutable<framework::SelectedRows>();
slr->set_height(1000); slr->set_height(20000);
auto* tensor = slr->mutable_value(); auto* tensor = slr->mutable_value();
auto* rows = slr->mutable_rows(); auto* rows = slr->mutable_rows();
tensor->Resize(framework::make_ddim({3, 5})); tensor->Resize(framework::make_ddim({20000, 1024}));
tensor->mutable_data<float>(place); tensor->mutable_data<float>(place);
paddle::operators::math::set_constant(ctx, tensor, 32.7); paddle::operators::math::set_constant(ctx, tensor, 32.7);
...@@ -83,6 +83,7 @@ void Gather(const std::vector<distributed::RemoteVar>& vars, ...@@ -83,6 +83,7 @@ void Gather(const std::vector<distributed::RemoteVar>& vars,
} }
TEST(PREFETCH, GPU) { TEST(PREFETCH, GPU) {
setenv("FLAGS_max_body_size", "2147483647", 1);
platform::CUDAPlace place; platform::CUDAPlace place;
platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance(); platform::DeviceContextPool& pool = platform::DeviceContextPool::Instance();
auto& ctx = *pool.Get(place); auto& ctx = *pool.Get(place);
......
...@@ -84,11 +84,15 @@ bool IsCompiledWithCUDA() { ...@@ -84,11 +84,15 @@ bool IsCompiledWithCUDA() {
} }
bool IsCompiledWithBrpc() { bool IsCompiledWithBrpc() {
#if defined(PADDLE_WITH_BRPC) || defined(PADDLE_WITH_BRPC_RDMA) #ifndef PADDLE_WITH_DISTRIBUTE
return true;
#else
return false; return false;
#endif #endif
#ifdef PADDLE_WITH_GRPC
return false;
#endif
return true;
} }
bool IsCompiledWithDIST() { bool IsCompiledWithDIST() {
......
...@@ -28,20 +28,53 @@ int main(int argc, char** argv) { ...@@ -28,20 +28,53 @@ int main(int argc, char** argv) {
for (int i = 0; i < argc; ++i) { for (int i = 0; i < argc; ++i) {
new_argv.push_back(argv[i]); new_argv.push_back(argv[i]);
} }
std::vector<std::string> envs;
std::vector<std::string> undefok;
#if defined(PADDLE_WITH_DISTRIBUTE) && !defined(PADDLE_WITH_GRPC)
envs.push_back("max_body_size");
#endif
#if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP)
new_argv.push_back( envs.push_back("fraction_of_gpu_memory_to_use");
strdup("--tryfromenv=fraction_of_gpu_memory_to_use,allocator_strategy")); envs.push_back("allocator_strategy");
#elif __clang__ #elif __clang__
new_argv.push_back( envs.push_back("use_mkldnn");
strdup("--tryfromenv=use_mkldnn,initial_cpu_memory_in_" envs.push_back("initial_cpu_memory_in_mb");
"mb,allocator_strategy")); envs.push_back("allocator_strategy");
new_argv.push_back(strdup("--undefok=use_mkldnn,initial_cpu_memory_in_mb"));
undefok.push_back("use_mkldnn");
undefok.push_back("initial_cpu_memory_in_mb");
#else #else
new_argv.push_back( envs.push_back("use_pinned_memory");
strdup("--tryfromenv=use_pinned_memory,use_mkldnn,initial_cpu_memory_in_" envs.push_back("use_mkldnn");
"mb,allocator_strategy")); envs.push_back("initial_cpu_memory_in_mb");
new_argv.push_back(strdup("--undefok=use_mkldnn,initial_cpu_memory_in_mb")); envs.push_back("allocator_strategy");
undefok.push_back("use_mkldnn");
undefok.push_back("initial_cpu_memory_in_mb");
#endif #endif
if (envs.size() > 0) {
std::string env_string = "--tryfromenv=";
for (auto t : envs) {
env_string += t + ",";
}
env_string = env_string.substr(0, env_string.length() - 1);
new_argv.push_back(strdup(env_string.c_str()));
VLOG(1) << "gtest env_string:" << env_string;
}
if (undefok.size() > 0) {
std::string undefok_string = "--undefok=";
for (auto t : undefok) {
undefok_string += t + ",";
}
undefok_string = undefok_string.substr(0, undefok_string.length() - 1);
new_argv.push_back(strdup(undefok_string.c_str()));
VLOG(1) << "gtest undefok_string:" << undefok_string;
}
int new_argc = static_cast<int>(new_argv.size()); int new_argc = static_cast<int>(new_argv.size());
char** new_argv_address = new_argv.data(); char** new_argv_address = new_argv.data();
google::ParseCommandLineFlags(&new_argc, &new_argv_address, false); google::ParseCommandLineFlags(&new_argc, &new_argv_address, false);
......
...@@ -151,6 +151,10 @@ def __bootstrap__(): ...@@ -151,6 +151,10 @@ def __bootstrap__():
read_env_flags.append('rpc_get_thread_num') read_env_flags.append('rpc_get_thread_num')
read_env_flags.append('rpc_prefetch_thread_num') read_env_flags.append('rpc_prefetch_thread_num')
read_env_flags.append('rpc_disable_reuse_port') read_env_flags.append('rpc_disable_reuse_port')
if core.is_compiled_with_brpc():
read_env_flags.append('max_body_size')
#set brpc max body size
os.environ['FLAGS_max_body_size'] = "2147483647"
if core.is_compiled_with_cuda(): if core.is_compiled_with_cuda():
read_env_flags += [ read_env_flags += [
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册