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

make_conv_workspace_size_configurable, test=release/1.6 (#20664)

上级 06e35ae4
...@@ -318,7 +318,7 @@ void Conv2DOpMaker::Make() { ...@@ -318,7 +318,7 @@ void Conv2DOpMaker::Make() {
"allocated/freed each time the operator runs, larger " "allocated/freed each time the operator runs, larger "
"workspace size can increase performance but also requires " "workspace size can increase performance but also requires "
"better hardware. This size should be chosen carefully.") "better hardware. This size should be chosen carefully.")
.SetDefault(platform::kDefaultConvWorkspaceSizeLimitMB); .SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB());
AddAttr<bool>("exhaustive_search", AddAttr<bool>("exhaustive_search",
"(bool, default false) cuDNN has many algorithm to calculation " "(bool, default false) cuDNN has many algorithm to calculation "
"convolution, whether enable exhaustive search " "convolution, whether enable exhaustive search "
...@@ -455,7 +455,7 @@ void Conv3DOpMaker::Make() { ...@@ -455,7 +455,7 @@ void Conv3DOpMaker::Make() {
"allocated/freed each time the operator runs, larger " "allocated/freed each time the operator runs, larger "
"workspace size can increase performance but also requires " "workspace size can increase performance but also requires "
"better hardware. This size should be chosen carefully.") "better hardware. This size should be chosen carefully.")
.SetDefault(platform::kDefaultConvWorkspaceSizeLimitMB); .SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB());
AddAttr<bool>("exhaustive_search", AddAttr<bool>("exhaustive_search",
"(bool, default false) cuDNN has many algorithm to calculation " "(bool, default false) cuDNN has many algorithm to calculation "
"convolution, whether enable exhaustive search " "convolution, whether enable exhaustive search "
......
...@@ -222,7 +222,7 @@ void Conv2DTransposeOpMaker::Make() { ...@@ -222,7 +222,7 @@ void Conv2DTransposeOpMaker::Make() {
"allocated/freed each time the operator runs, larger " "allocated/freed each time the operator runs, larger "
"workspace size can increase performance but also requires " "workspace size can increase performance but also requires "
"better hardward. This size should be carefully setted.") "better hardward. This size should be carefully setted.")
.SetDefault(platform::kDefaultConvWorkspaceSizeLimitMB); .SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB());
AddComment(R"DOC( AddComment(R"DOC(
Convolution2D Transpose Operator. Convolution2D Transpose Operator.
...@@ -323,7 +323,7 @@ void Conv3DTransposeOpMaker::Make() { ...@@ -323,7 +323,7 @@ void Conv3DTransposeOpMaker::Make() {
"allocated/freed each time the operator runs, larger " "allocated/freed each time the operator runs, larger "
"workspace size can increase performance but also requires " "workspace size can increase performance but also requires "
"better hardward. This size should be carefully setted.") "better hardward. This size should be carefully setted.")
.SetDefault(platform::kDefaultConvWorkspaceSizeLimitMB); .SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB());
AddComment(R"DOC( AddComment(R"DOC(
Convolution3D Transpose Operator. Convolution3D Transpose Operator.
......
...@@ -96,7 +96,7 @@ class ConvInceptionFusionOpMaker : public framework::OpProtoAndCheckerMaker { ...@@ -96,7 +96,7 @@ class ConvInceptionFusionOpMaker : public framework::OpProtoAndCheckerMaker {
"allocated/freed each time the operator runs, larger " "allocated/freed each time the operator runs, larger "
"workspace size can increase performance but also requires " "workspace size can increase performance but also requires "
"better hardware. This size should be chosen carefully.") "better hardware. This size should be chosen carefully.")
.SetDefault(platform::kDefaultConvWorkspaceSizeLimitMB); .SetDefault(platform::GetDefaultConvWorkspaceSizeLimitMB());
AddComment(R"DOC( AddComment(R"DOC(
)DOC"); )DOC");
} }
......
...@@ -68,11 +68,13 @@ ELSE() ...@@ -68,11 +68,13 @@ ELSE()
set(STREAM_CALLBACK_DEPS) set(STREAM_CALLBACK_DEPS)
ENDIF() ENDIF()
cc_library(cudnn_workspace_helper SRCS cudnn_workspace_helper.cc DEPS boost)
# memcpy depends on device_context, here add deps individually for # memcpy depends on device_context, here add deps individually for
# avoiding cycle dependencies # avoiding cycle dependencies
cc_library(device_context SRCS device_context.cc init.cc DEPS simple_threadpool malloc xxhash ${STREAM_CALLBACK_DEPS} 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} 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) if (WITH_DISTRIBUTE)
cc_library(collective_helper SRCS collective_helper.cc DEPS framework_proto device_context enforce) 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 { ...@@ -19,5 +19,7 @@ namespace platform {
static constexpr int kDefaultConvWorkspaceSizeLimitMB = 512; static constexpr int kDefaultConvWorkspaceSizeLimitMB = 512;
int GetDefaultConvWorkspaceSizeLimitMB();
} // namespace platform } // namespace platform
} // namespace paddle } // namespace paddle
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册