Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
TonyTonyFun
Paddle
提交
c3bcd3c1
P
Paddle
项目概览
TonyTonyFun
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
c3bcd3c1
编写于
1月 08, 2020
作者:
Z
Zeng Jinle
提交者:
GitHub
1月 08, 2020
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix dygraph non zero gpu bug, test=develop (#22165)
上级
cfb0c12e
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
1 deletion
+43
-1
paddle/fluid/memory/allocation/cuda_allocator.cc
paddle/fluid/memory/allocation/cuda_allocator.cc
+2
-0
paddle/fluid/memory/allocation/cuda_allocator.h
paddle/fluid/memory/allocation/cuda_allocator.h
+2
-0
python/paddle/fluid/tests/unittests/CMakeLists.txt
python/paddle/fluid/tests/unittests/CMakeLists.txt
+1
-1
python/paddle/fluid/tests/unittests/test_imperative_using_non_zero_gpu.py
...uid/tests/unittests/test_imperative_using_non_zero_gpu.py
+38
-0
未找到文件。
paddle/fluid/memory/allocation/cuda_allocator.cc
浏览文件 @
c3bcd3c1
...
...
@@ -33,6 +33,8 @@ void CUDAAllocator::FreeImpl(Allocation* allocation) {
}
Allocation
*
CUDAAllocator
::
AllocateImpl
(
size_t
size
)
{
std
::
call_once
(
once_flag_
,
[
this
]
{
platform
::
SetDeviceId
(
place_
.
device
);
});
platform
::
CUDADeviceGuard
guard
(
place_
.
device
);
void
*
ptr
;
auto
result
=
cudaMalloc
(
&
ptr
,
size
);
...
...
paddle/fluid/memory/allocation/cuda_allocator.h
浏览文件 @
c3bcd3c1
...
...
@@ -13,6 +13,7 @@
// limitations under the License.
#pragma once
#include <mutex> // NOLINT
#include "paddle/fluid/memory/allocation/allocator.h"
#include "paddle/fluid/platform/place.h"
...
...
@@ -33,6 +34,7 @@ class CUDAAllocator : public Allocator {
private:
platform
::
CUDAPlace
place_
;
std
::
once_flag
once_flag_
;
};
}
// namespace allocation
...
...
python/paddle/fluid/tests/unittests/CMakeLists.txt
浏览文件 @
c3bcd3c1
...
...
@@ -330,5 +330,5 @@ set_tests_properties(test_parallel_executor_test_while_train test_parallel_execu
test_parallel_executor_crf test_sync_batch_norm_op
test_parallel_executor_feed_persistable_var
test_parallel_executor_crf_auto_growth test_buffer_shared_memory_reuse_pass_and_fuse_optimization_op_pass
test_data_norm_op
test_data_norm_op
test_imperative_using_non_zero_gpu
test_buffer_shared_memory_reuse_pass PROPERTIES LABELS
"RUN_TYPE=DIST"
)
python/paddle/fluid/tests/unittests/test_imperative_using_non_zero_gpu.py
0 → 100644
浏览文件 @
c3bcd3c1
# Copyright (c) 2020 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.
import
paddle.fluid
as
fluid
import
unittest
from
paddle.fluid.dygraph
import
to_variable
,
Embedding
,
guard
import
numpy
as
np
class
TestImperativeUsingNonZeroGpu
(
unittest
.
TestCase
):
def
run_main
(
self
,
np_arr
,
place
):
with
guard
(
place
):
embedding
=
Embedding
(
size
=
[
10
,
10
])
var
=
to_variable
(
np_arr
)
self
.
assertTrue
(
np
.
array_equal
(
np_arr
,
var
.
numpy
()))
def
test_non_zero_gpu
(
self
):
if
not
fluid
.
is_compiled_with_cuda
():
return
np_arr
=
np
.
random
.
random
([
11
,
13
]).
astype
(
'float32'
)
self
.
run_main
(
np_arr
,
fluid
.
CUDAPlace
(
1
))
self
.
run_main
(
np_arr
,
fluid
.
CUDAPlace
(
0
))
if
__name__
==
'__main__'
:
unittest
.
main
()
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录