未验证 提交 4922eb6d 编写于 作者: Z Zeng Jinle 提交者: GitHub

make_conv_workspace_size_configurable, test=develop (#20662)

上级 96f73569
......@@ -318,7 +318,7 @@ void Conv2DOpMaker::Make() {
"allocated/freed each time the operator runs, larger "
"workspace size can increase performance but also requires "
"better hardware. This size should be chosen carefully.")
.SetDefault(platform::kDefaultConvWorkspaceSizeLimitMB);
.SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB());
AddAttr<bool>("exhaustive_search",
"(bool, default false) cuDNN has many algorithm to calculation "
"convolution, whether enable exhaustive search "
......@@ -455,7 +455,7 @@ void Conv3DOpMaker::Make() {
"allocated/freed each time the operator runs, larger "
"workspace size can increase performance but also requires "
"better hardware. This size should be chosen carefully.")
.SetDefault(platform::kDefaultConvWorkspaceSizeLimitMB);
.SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB());
AddAttr<bool>("exhaustive_search",
"(bool, default false) cuDNN has many algorithm to calculation "
"convolution, whether enable exhaustive search "
......
......@@ -222,7 +222,7 @@ void Conv2DTransposeOpMaker::Make() {
"allocated/freed each time the operator runs, larger "
"workspace size can increase performance but also requires "
"better hardward. This size should be carefully setted.")
.SetDefault(platform::kDefaultConvWorkspaceSizeLimitMB);
.SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB());
AddComment(R"DOC(
Convolution2D Transpose Operator.
......@@ -323,7 +323,7 @@ void Conv3DTransposeOpMaker::Make() {
"allocated/freed each time the operator runs, larger "
"workspace size can increase performance but also requires "
"better hardward. This size should be carefully setted.")
.SetDefault(platform::kDefaultConvWorkspaceSizeLimitMB);
.SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB());
AddComment(R"DOC(
Convolution3D Transpose Operator.
......
......@@ -96,7 +96,7 @@ class ConvInceptionFusionOpMaker : public framework::OpProtoAndCheckerMaker {
"allocated/freed each time the operator runs, larger "
"workspace size can increase performance but also requires "
"better hardware. This size should be chosen carefully.")
.SetDefault(platform::kDefaultConvWorkspaceSizeLimitMB);
.SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB());
AddComment(R"DOC(
)DOC");
}
......
......@@ -68,11 +68,13 @@ ELSE()
set(STREAM_CALLBACK_DEPS)
ENDIF()
cc_library(cudnn_workspace_helper SRCS cudnn_workspace_helper.cc DEPS boost)
# memcpy depends on device_context, here add deps individually for
# avoiding cycle dependencies
cc_library(device_context SRCS device_context.cc init.cc DEPS simple_threadpool malloc xxhash ${STREAM_CALLBACK_DEPS}
place eigen3 stringpiece cpu_helper cpu_info framework_proto ${GPU_CTX_DEPS} ${MKLDNN_CTX_DEPS}
${dgc_deps} dlpack)
${dgc_deps} dlpack cudnn_workspace_helper)
if (WITH_DISTRIBUTE)
cc_library(collective_helper SRCS collective_helper.cc DEPS framework_proto device_context enforce)
......
// Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
#include "paddle/fluid/platform/cudnn_workspace_helper.h"
#include <cstdlib>
#include <string>
#include "boost/lexical_cast.hpp"
namespace paddle {
namespace platform {
static int GetDefaultConvWorkspaceSizeLimitMBImpl() {
const char *env_str = std::getenv("FLAGS_conv_workspace_size_limit");
return env_str ? boost::lexical_cast<int>(std::string(env_str))
: kDefaultConvWorkspaceSizeLimitMB;
}
int GetDefaultConvWorkspaceSizeLimitMB() {
static auto workspace_size = GetDefaultConvWorkspaceSizeLimitMBImpl();
return workspace_size;
}
} // namespace platform
} // namespace paddle
......@@ -19,5 +19,7 @@ namespace platform {
static constexpr int kDefaultConvWorkspaceSizeLimitMB = 512;
int GetDefaultConvWorkspaceSizeLimitMB();
} // namespace platform
} // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册