File tree Expand file tree Collapse file tree 6 files changed +45
-6
lines changed Expand file tree Collapse file tree 6 files changed +45
-6
lines changed Original file line number Diff line number Diff line change @@ -318,7 +318,7 @@ void Conv2DOpMaker::Make() {
318
318
" allocated/freed each time the operator runs, larger "
319
319
" workspace size can increase performance but also requires "
320
320
" better hardware. This size should be chosen carefully." )
321
- .SetDefault (platform::kDefaultConvWorkspaceSizeLimitMB );
321
+ .SetDefault (platform::GetDefaultConvWorkspaceSizeLimitMB () );
322
322
AddAttr<bool >(" exhaustive_search" ,
323
323
" (bool, default false) cuDNN has many algorithm to calculation "
324
324
" convolution, whether enable exhaustive search "
@@ -455,7 +455,7 @@ void Conv3DOpMaker::Make() {
455
455
" allocated/freed each time the operator runs, larger "
456
456
" workspace size can increase performance but also requires "
457
457
" better hardware. This size should be chosen carefully." )
458
- .SetDefault (platform::kDefaultConvWorkspaceSizeLimitMB );
458
+ .SetDefault (platform::GetDefaultConvWorkspaceSizeLimitMB () );
459
459
AddAttr<bool >(" exhaustive_search" ,
460
460
" (bool, default false) cuDNN has many algorithm to calculation "
461
461
" convolution, whether enable exhaustive search "
Original file line number Diff line number Diff line change @@ -222,7 +222,7 @@ void Conv2DTransposeOpMaker::Make() {
222
222
" allocated/freed each time the operator runs, larger "
223
223
" workspace size can increase performance but also requires "
224
224
" better hardward. This size should be carefully setted." )
225
- .SetDefault (platform::kDefaultConvWorkspaceSizeLimitMB );
225
+ .SetDefault (platform::GetDefaultConvWorkspaceSizeLimitMB () );
226
226
AddComment (R"DOC(
227
227
Convolution2D Transpose Operator.
228
228
@@ -323,7 +323,7 @@ void Conv3DTransposeOpMaker::Make() {
323
323
" allocated/freed each time the operator runs, larger "
324
324
" workspace size can increase performance but also requires "
325
325
" better hardward. This size should be carefully setted." )
326
- .SetDefault (platform::kDefaultConvWorkspaceSizeLimitMB );
326
+ .SetDefault (platform::GetDefaultConvWorkspaceSizeLimitMB () );
327
327
AddComment (R"DOC(
328
328
Convolution3D Transpose Operator.
329
329
Original file line number Diff line number Diff line change @@ -96,7 +96,7 @@ class ConvInceptionFusionOpMaker : public framework::OpProtoAndCheckerMaker {
96
96
" allocated/freed each time the operator runs, larger "
97
97
" workspace size can increase performance but also requires "
98
98
" better hardware. This size should be chosen carefully." )
99
- .SetDefault (platform::kDefaultConvWorkspaceSizeLimitMB );
99
+ .SetDefault (platform::GetDefaultConvWorkspaceSizeLimitMB () );
100
100
AddComment (R"DOC(
101
101
)DOC" );
102
102
}
Original file line number Diff line number Diff line change @@ -68,11 +68,13 @@ ELSE()
68
68
set (STREAM_CALLBACK_DEPS )
69
69
ENDIF ()
70
70
71
+ cc_library (cudnn_workspace_helper SRCS cudnn_workspace_helper.cc DEPS boost )
72
+
71
73
# memcpy depends on device_context, here add deps individually for
72
74
# avoiding cycle dependencies
73
75
cc_library (device_context SRCS device_context.cc init.cc DEPS simple_threadpool malloc xxhash ${STREAM_CALLBACK_DEPS}
74
76
place eigen3 stringpiece cpu_helper cpu_info framework_proto ${GPU_CTX_DEPS} ${MKLDNN_CTX_DEPS}
75
- ${dgc_deps} dlpack )
77
+ ${dgc_deps} dlpack cudnn_workspace_helper )
76
78
77
79
if (WITH_DISTRIBUTE )
78
80
cc_library (collective_helper SRCS collective_helper.cc DEPS framework_proto device_context enforce )
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2019 PaddlePaddle Authors. All Rights Reserved.
2
+ //
3
+ // Licensed under the Apache License, Version 2.0 (the "License");
4
+ // you may not use this file except in compliance with the License.
5
+ // You may obtain a copy of the License at
6
+ //
7
+ // http://www.apache.org/licenses/LICENSE-2.0
8
+ //
9
+ // Unless required by applicable law or agreed to in writing, software
10
+ // distributed under the License is distributed on an "AS IS" BASIS,
11
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ // See the License for the specific language governing permissions and
13
+ // limitations under the License.
14
+
15
+ #include " paddle/fluid/platform/cudnn_workspace_helper.h"
16
+ #include < cstdlib>
17
+ #include < string>
18
+ #include " boost/lexical_cast.hpp"
19
+
20
+ namespace paddle {
21
+ namespace platform {
22
+
23
+ static int GetDefaultConvWorkspaceSizeLimitMBImpl () {
24
+ const char *env_str = std::getenv (" FLAGS_conv_workspace_size_limit" );
25
+ return env_str ? boost::lexical_cast<int >(std::string (env_str))
26
+ : kDefaultConvWorkspaceSizeLimitMB ;
27
+ }
28
+
29
+ int GetDefaultConvWorkspaceSizeLimitMB () {
30
+ static auto workspace_size = GetDefaultConvWorkspaceSizeLimitMBImpl ();
31
+ return workspace_size;
32
+ }
33
+
34
+ } // namespace platform
35
+ } // namespace paddle
Original file line number Diff line number Diff line change @@ -19,5 +19,7 @@ namespace platform {
19
19
20
20
static constexpr int kDefaultConvWorkspaceSizeLimitMB = 512 ;
21
21
22
+ int GetDefaultConvWorkspaceSizeLimitMB ();
23
+
22
24
} // namespace platform
23
25
} // namespace paddle
You can’t perform that action at this time.
0 commit comments