Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
机器未来
Paddle
提交
f962bd34
P
Paddle
项目概览
机器未来
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
未验证
提交
f962bd34
编写于
11月 16, 2020
作者:
L
Leo Chen
提交者:
GitHub
11月 16, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix cudnn workspace limit in cudnn-8 (#28611)
上级
90805e2d
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
44 addition
and
5 deletion
+44
-5
paddle/fluid/operators/conv_cudnn_helper.h
paddle/fluid/operators/conv_cudnn_helper.h
+44
-5
未找到文件。
paddle/fluid/operators/conv_cudnn_helper.h
浏览文件 @
f962bd34
...
...
@@ -19,6 +19,7 @@ limitations under the License. */
#include <memory>
#include <string>
#include <vector>
#include "paddle/fluid/framework/conv_search_cache.h"
#include "paddle/fluid/framework/operator_kernel_configs.h"
#include "paddle/fluid/operators/conv_cudnn_op_cache.h"
...
...
@@ -101,6 +102,24 @@ inline int MaxBwdFilterAlgos(cudnnHandle_t cudnn_handle) {
return
max_algos
;
}
template
<
typename
PerfType
,
typename
AlgoType
>
void
ChooseAlgoByWorkspace
(
PerfType
*
perf_results
,
size_t
perf_num
,
size_t
workspace_byte
,
AlgoType
*
algo
)
{
for
(
size_t
i
=
0
;
i
<
perf_num
;
++
i
)
{
auto
result
=
perf_results
[
i
];
if
(
result
.
status
==
CUDNN_STATUS_SUCCESS
&&
result
.
memory
<
workspace_byte
)
{
*
algo
=
result
.
algo
;
VLOG
(
3
)
<<
" algo: "
<<
result
.
algo
<<
", time: "
<<
result
.
time
<<
" ms, wksp = "
<<
result
.
memory
<<
", status = "
<<
result
.
status
;
return
;
}
}
VLOG
(
3
)
<<
"Can not find alog that requires memory < "
<<
static_cast
<
double
>
(
workspace_byte
)
/
(
1
<<
20
)
<<
" MB"
;
}
template
<
typename
PerfType
,
typename
AlgoType
>
void
ChooseAlgo
(
const
std
::
vector
<
PerfType
>&
perf_results
,
size_t
workspace_byte
,
AlgoType
*
algo
)
{
...
...
@@ -219,7 +238,10 @@ struct SearchAlgorithm<cudnnConvolutionFwdAlgoPerf_t> {
if
(
workspace_size
>
workspace_size_limit
)
{
#if CUDNN_VERSION >= 8000
workspace_size_limit
=
workspace_size
;
// cudnnGetConvolutionForwardAlgorithm is removed in CUDNN-8
ChooseAlgoByWorkspace
<
perf_t
,
algo_t
>
(
perf_results
.
get
(),
kNUM_CUDNN_FWD_ALGS
,
workspace_size_limit
,
&
algo
);
#else
VLOG
(
1
)
<<
"Fallback to non-v7 method to find conv algorithm becasue "
"the workspace size request("
...
...
@@ -316,7 +338,6 @@ struct SearchAlgorithm<cudnnConvolutionBwdDataAlgoPerf_t> {
size_t
workspace_size
=
0
;
bool
has_got_workspace_size
=
true
;
algo_t
algo
;
#if CUDA_VERSION >= 9000 && CUDNN_VERSION_MIN(7, 0, 1)
auto
&
dev_ctx
=
ctx
.
template
device_context
<
platform
::
CUDADeviceContext
>();
if
(
dev_ctx
.
GetComputeCapability
()
>=
70
&&
dtype
==
CUDNN_DATA_HALF
)
{
...
...
@@ -362,9 +383,10 @@ struct SearchAlgorithm<cudnnConvolutionBwdDataAlgoPerf_t> {
if
(
workspace_size
>
workspace_size_limit
)
{
has_got_workspace_size
=
false
;
#if CUDNN_VERSION >= 8000
// There is no cudnnGetConvolutionBackwardDataAlgorithm in CUDNN 8
// version.
workspace_size_limit
=
workspace_size
;
// cudnnGetConvolutionBackwardDataAlgorithm is removed in CUDNN-8
ChooseAlgoByWorkspace
<
perf_t
,
algo_t
>
(
perf_results
.
get
(),
kNUM_CUDNN_BWD_DATA_ALGS
,
workspace_size_limit
,
&
algo
);
#else
VLOG
(
1
)
<<
"Fallback to non-v7 method to find conv algorithm becasue "
"the workspace size request("
...
...
@@ -493,6 +515,23 @@ struct SearchAlgorithm<cudnnConvolutionBwdFilterAlgoPerf_t> {
workspace_size
=
GetWorkspaceSize
(
args
,
algo
);
if
(
workspace_size
>
workspace_size_limit
)
{
workspace_size
=
workspace_size_limit
;
#if CUDNN_VERSION >= 8000
// cudnnGetConvolutionBackwardFilterAlgorithm is removed in CUDNN-8
ChooseAlgoByWorkspace
<
perf_t
,
algo_t
>
(
perf_results
.
get
(),
kNUM_CUDNN_BWD_FILTER_ALGS
,
workspace_size_limit
,
&
algo
);
#else
VLOG
(
1
)
<<
"Fallback to non-v7 method to find conv algorithm becasue "
"the workspace size request("
<<
workspace_size
<<
") exceeds the limit("
<<
workspace_size_limit
<<
")"
;
PADDLE_ENFORCE_CUDA_SUCCESS
(
platform
::
dynload
::
cudnnGetConvolutionBackwardFilterAlgorithm
(
args
.
handle
,
args
.
idesc
.
desc
(),
args
.
odesc
.
desc
(),
args
.
cdesc
.
desc
(),
args
.
wdesc
.
desc
(),
CUDNN_CONVOLUTION_BWD_FILTER_SPECIFY_WORKSPACE_LIMIT
,
workspace_size_limit
,
&
algo
));
#endif
}
#else
PADDLE_ENFORCE_CUDA_SUCCESS
(
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录