Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
8e3fdc6e
P
Paddle
项目概览
Crayon鑫
/
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看板
提交
8e3fdc6e
编写于
9月 29, 2018
作者:
Y
Yu Yang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix SetDevice on init
上级
524f6e9b
变更
7
显示空白变更内容
内联
并排
Showing
7 changed file
with
52 addition
and
6 deletion
+52
-6
paddle/fluid/memory/allocation/CMakeLists.txt
paddle/fluid/memory/allocation/CMakeLists.txt
+2
-0
paddle/fluid/memory/allocation/allocation_and_eigen_test.cu
paddle/fluid/memory/allocation/allocation_and_eigen_test.cu
+45
-0
paddle/fluid/memory/allocation/allocator_facade.cc
paddle/fluid/memory/allocation/allocator_facade.cc
+0
-1
paddle/fluid/memory/allocation/cuda_allocator.cc
paddle/fluid/memory/allocation/cuda_allocator.cc
+0
-1
paddle/fluid/operators/math/CMakeLists.txt
paddle/fluid/operators/math/CMakeLists.txt
+1
-1
paddle/fluid/platform/device_context.cc
paddle/fluid/platform/device_context.cc
+2
-2
paddle/fluid/platform/init.cc
paddle/fluid/platform/init.cc
+2
-1
未找到文件。
paddle/fluid/memory/allocation/CMakeLists.txt
浏览文件 @
8e3fdc6e
...
@@ -42,3 +42,5 @@ cc_library(allocator_facade SRCS allocator_facade.cc DEPS
...
@@ -42,3 +42,5 @@ cc_library(allocator_facade SRCS allocator_facade.cc DEPS
naive_managed_allocator
naive_managed_allocator
aligned_allocator
aligned_allocator
cuda_device_guard
)
cuda_device_guard
)
nv_test
(
allocation_and_eigen_test SRCS allocation_and_eigen_test.cu DEPS allocator_facade
)
paddle/fluid/memory/allocation/allocation_and_eigen_test.cu
0 → 100644
浏览文件 @
8e3fdc6e
// Copyright (c) 2018 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 "gtest/gtest.h"
#include "paddle/fluid/framework/eigen.h"
#include "paddle/fluid/framework/tensor.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/for_range.h"
#include "unsupported/Eigen/CXX11/Tensor"
struct
FillZero
{
public:
float
*
ptr_
;
__device__
void
operator
()(
size_t
i
)
{
ptr_
[
i
]
=
0.0
f
;
}
};
namespace
paddle
{
TEST
(
Eigen
,
main
)
{
framework
::
Tensor
tensor
;
platform
::
CUDAPlace
gpu
(
0
);
float
*
ptr
=
tensor
.
mutable_data
<
float
>
({
10
,
10
},
gpu
);
auto
&
dev_ctx
=
*
reinterpret_cast
<
platform
::
CUDADeviceContext
*>
(
platform
::
DeviceContextPool
::
Instance
().
Get
(
gpu
));
PADDLE_ENFORCE
(
cudaMemset
(
ptr
,
0
,
sizeof
(
float
)
*
100
));
platform
::
ForRange
<
platform
::
CUDADeviceContext
>
for_range
(
dev_ctx
,
100
);
for_range
(
FillZero
{
ptr
});
dev_ctx
.
Wait
();
auto
eigen_vec
=
framework
::
EigenVector
<
float
>::
Flatten
(
tensor
);
auto
&
eigen_dev
=
*
dev_ctx
.
eigen_device
();
eigen_vec
.
device
(
eigen_dev
)
=
eigen_vec
.
constant
(
0.0
f
);
}
}
// namespace paddle
paddle/fluid/memory/allocation/allocator_facade.cc
浏览文件 @
8e3fdc6e
...
@@ -46,7 +46,6 @@ class AllocatorFacadePrivate {
...
@@ -46,7 +46,6 @@ class AllocatorFacadePrivate {
}
}
AllocatorFacadePrivate
()
{
AllocatorFacadePrivate
()
{
std
::
cout
<<
"Init Allocator Facade"
<<
std
::
endl
;
InitCPUAllocator
();
InitCPUAllocator
();
InitCUDAAllocator
();
InitCUDAAllocator
();
}
}
...
...
paddle/fluid/memory/allocation/cuda_allocator.cc
浏览文件 @
8e3fdc6e
...
@@ -31,7 +31,6 @@ std::unique_ptr<Allocation> CUDAAllocator::Allocate(size_t size, Attr attr) {
...
@@ -31,7 +31,6 @@ std::unique_ptr<Allocation> CUDAAllocator::Allocate(size_t size, Attr attr) {
"Cannot allocate %d on GPU %d, cuda status %d, %s"
,
size
,
place_
.
device
,
"Cannot allocate %d on GPU %d, cuda status %d, %s"
,
size
,
place_
.
device
,
status
,
cudaGetErrorString
(
status
)));
status
,
cudaGetErrorString
(
status
)));
}
}
return
std
::
unique_ptr
<
Allocation
>
(
return
std
::
unique_ptr
<
Allocation
>
(
new
CUDAAllocation
(
ptr
,
size
,
platform
::
Place
(
place_
)));
new
CUDAAllocation
(
ptr
,
size
,
platform
::
Place
(
place_
)));
}
}
...
...
paddle/fluid/operators/math/CMakeLists.txt
浏览文件 @
8e3fdc6e
...
@@ -72,7 +72,7 @@ cc_test(vol2col_test SRCS vol2col_test.cc DEPS vol2col)
...
@@ -72,7 +72,7 @@ cc_test(vol2col_test SRCS vol2col_test.cc DEPS vol2col)
cc_test
(
sequence_padding_test SRCS sequence_padding_test.cc DEPS sequence_padding
)
cc_test
(
sequence_padding_test SRCS sequence_padding_test.cc DEPS sequence_padding
)
if
(
WITH_GPU
)
if
(
WITH_GPU
)
nv_test
(
math_function_gpu_test SRCS math_function_test.cu DEPS math_function
)
nv_test
(
math_function_gpu_test SRCS math_function_test.cu DEPS math_function
)
nv_test
(
selected_rows_functor_gpu_test SRCS selected_rows_functor_test.cu DEPS selected_rows_functor math_function
)
nv_test
(
selected_rows_functor_gpu_test SRCS selected_rows_functor_test.cu
.cc
DEPS selected_rows_functor math_function
)
endif
()
endif
()
cc_test
(
concat_test SRCS concat_test.cc DEPS concat
)
cc_test
(
concat_test SRCS concat_test.cc DEPS concat
)
cc_test
(
cpu_vec_test SRCS cpu_vec_test.cc DEPS blas cpu_info
)
cc_test
(
cpu_vec_test SRCS cpu_vec_test.cc DEPS blas cpu_info
)
paddle/fluid/platform/device_context.cc
浏览文件 @
8e3fdc6e
...
@@ -9,11 +9,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
...
@@ -9,11 +9,11 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
See the License for the specific language governing permissions and
limitations under the License. */
limitations under the License. */
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/device_context.h"
#include <set>
#include <set>
#include <string>
#include <string>
#include <unordered_set>
#include <unordered_set>
#include <vector>
#include <vector>
#include "paddle/fluid/platform/cuda_device_guard.h"
#include "paddle/fluid/memory/memory.h"
#include "paddle/fluid/memory/memory.h"
#ifdef PADDLE_WITH_CUDA
#ifdef PADDLE_WITH_CUDA
...
@@ -205,7 +205,7 @@ class CudnnHolder {
...
@@ -205,7 +205,7 @@ class CudnnHolder {
CUDADeviceContext
::
CUDADeviceContext
(
CUDAPlace
place
)
CUDADeviceContext
::
CUDADeviceContext
(
CUDAPlace
place
)
:
place_
(
place
),
cudnn_holder_
(
nullptr
)
{
:
place_
(
place
),
cudnn_holder_
(
nullptr
)
{
SetDeviceI
d
(
place_
.
device
);
CUDADeviceGuard
guar
d
(
place_
.
device
);
compute_capability
=
GetCUDAComputeCapability
(
place_
.
device
);
compute_capability
=
GetCUDAComputeCapability
(
place_
.
device
);
multi_process
=
GetCUDAMultiProcessors
(
place_
.
device
);
multi_process
=
GetCUDAMultiProcessors
(
place_
.
device
);
max_threads_per_mp
=
GetCUDAMaxThreadsPerMultiProcessor
(
place_
.
device
);
max_threads_per_mp
=
GetCUDAMaxThreadsPerMultiProcessor
(
place_
.
device
);
...
...
paddle/fluid/platform/init.cc
浏览文件 @
8e3fdc6e
...
@@ -19,6 +19,7 @@ limitations under the License. */
...
@@ -19,6 +19,7 @@ limitations under the License. */
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/framework/operator.h"
#include "paddle/fluid/platform/cpu_helper.h"
#include "paddle/fluid/platform/cpu_helper.h"
#include "paddle/fluid/platform/cpu_info.h"
#include "paddle/fluid/platform/cpu_info.h"
#include "paddle/fluid/platform/cuda_device_guard.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/device_context.h"
#include "paddle/fluid/platform/init.h"
#include "paddle/fluid/platform/init.h"
#include "paddle/fluid/platform/place.h"
#include "paddle/fluid/platform/place.h"
...
@@ -64,7 +65,7 @@ void InitP2P(std::vector<int> devices) {
...
@@ -64,7 +65,7 @@ void InitP2P(std::vector<int> devices) {
LOG
(
WARNING
)
<<
"Cannot enable P2P access from "
<<
devices
[
i
]
LOG
(
WARNING
)
<<
"Cannot enable P2P access from "
<<
devices
[
i
]
<<
" to "
<<
devices
[
j
];
<<
" to "
<<
devices
[
j
];
}
else
{
}
else
{
cudaSetDevice
(
devices
[
i
]);
platform
::
CUDADeviceGuard
guard
(
devices
[
i
]);
cudaDeviceEnablePeerAccess
(
devices
[
j
],
0
);
cudaDeviceEnablePeerAccess
(
devices
[
j
],
0
);
}
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录