Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
9c360cc7
P
Paddle
项目概览
BaiXuePrincess
/
Paddle
与 Fork 源项目一致
Fork自
PaddlePaddle / Paddle
通知
1
Star
1
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看板
提交
9c360cc7
编写于
1月 24, 2019
作者:
S
sneaxiy
浏览文件
操作
浏览文件
下载
差异文件
test=develop
上级
d243e555
51227bd4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
37 addition
and
3 deletion
+37
-3
paddle/fluid/platform/gpu_info.cc
paddle/fluid/platform/gpu_info.cc
+19
-1
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+18
-2
未找到文件。
paddle/fluid/platform/gpu_info.cc
浏览文件 @
9c360cc7
...
@@ -15,6 +15,8 @@ limitations under the License. */
...
@@ -15,6 +15,8 @@ limitations under the License. */
#include "paddle/fluid/platform/gpu_info.h"
#include "paddle/fluid/platform/gpu_info.h"
#include <algorithm>
#include <algorithm>
#include <cstdlib>
#include <string>
#include "gflags/gflags.h"
#include "gflags/gflags.h"
#include "paddle/fluid/platform/enforce.h"
#include "paddle/fluid/platform/enforce.h"
...
@@ -58,7 +60,18 @@ DEFINE_string(selected_gpus, "",
...
@@ -58,7 +60,18 @@ DEFINE_string(selected_gpus, "",
namespace
paddle
{
namespace
paddle
{
namespace
platform
{
namespace
platform
{
int
GetCUDADeviceCount
()
{
static
int
GetCUDADeviceCountImpl
()
{
const
auto
*
cuda_visible_devices
=
std
::
getenv
(
"CUDA_VISIBLE_DEVICES"
);
if
(
cuda_visible_devices
!=
nullptr
)
{
std
::
string
cuda_visible_devices_str
(
cuda_visible_devices
);
if
(
std
::
all_of
(
cuda_visible_devices_str
.
begin
(),
cuda_visible_devices_str
.
end
(),
[](
char
ch
)
{
return
ch
==
' '
;
}))
{
VLOG
(
2
)
<<
"CUDA_VISIBLE_DEVICES is set to be empty. No GPU detected."
;
return
0
;
}
}
int
count
;
int
count
;
PADDLE_ENFORCE
(
PADDLE_ENFORCE
(
cudaGetDeviceCount
(
&
count
),
cudaGetDeviceCount
(
&
count
),
...
@@ -66,6 +79,11 @@ int GetCUDADeviceCount() {
...
@@ -66,6 +79,11 @@ int GetCUDADeviceCount() {
return
count
;
return
count
;
}
}
int
GetCUDADeviceCount
()
{
static
auto
dev_cnt
=
GetCUDADeviceCountImpl
();
return
dev_cnt
;
}
int
GetCUDAComputeCapability
(
int
id
)
{
int
GetCUDAComputeCapability
(
int
id
)
{
PADDLE_ENFORCE_LT
(
id
,
GetCUDADeviceCount
(),
"id must less than GPU count"
);
PADDLE_ENFORCE_LT
(
id
,
GetCUDADeviceCount
(),
"id must less than GPU count"
);
cudaDeviceProp
device_prop
;
cudaDeviceProp
device_prop
;
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
9c360cc7
...
@@ -626,7 +626,18 @@ All parameter, weight, gradient are variables in Paddle.
...
@@ -626,7 +626,18 @@ All parameter, weight, gradient are variables in Paddle.
py
::
class_
<
platform
::
Communicator
>
(
m
,
"Communicator"
).
def
(
py
::
init
<>
());
py
::
class_
<
platform
::
Communicator
>
(
m
,
"Communicator"
).
def
(
py
::
init
<>
());
#endif
#endif
py
::
class_
<
platform
::
CUDAPlace
>
(
m
,
"CUDAPlace"
)
py
::
class_
<
platform
::
CUDAPlace
>
(
m
,
"CUDAPlace"
)
.
def
(
py
::
init
<
int
>
())
.
def
(
"__init__"
,
[](
platform
::
CUDAPlace
&
self
,
int
dev_id
)
{
#ifdef PADDLE_WITH_CUDA
PADDLE_ENFORCE
(
dev_id
>=
0
&&
dev_id
<
platform
::
GetCUDADeviceCount
(),
"Invalid CUDAPlace(%d), must inside [0, %d)"
,
dev_id
,
platform
::
GetCUDADeviceCount
());
new
(
&
self
)
platform
::
CUDAPlace
(
dev_id
);
#else
PADDLE_THROW
(
"Cannot use CUDAPlace in CPU only version"
);
#endif
})
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CUDAPlace
&>
);
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CUDAPlace
&>
);
py
::
class_
<
paddle
::
platform
::
CPUPlace
>
(
m
,
"CPUPlace"
)
py
::
class_
<
paddle
::
platform
::
CPUPlace
>
(
m
,
"CPUPlace"
)
...
@@ -634,7 +645,12 @@ All parameter, weight, gradient are variables in Paddle.
...
@@ -634,7 +645,12 @@ All parameter, weight, gradient are variables in Paddle.
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CPUPlace
&>
);
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CPUPlace
&>
);
py
::
class_
<
paddle
::
platform
::
CUDAPinnedPlace
>
(
m
,
"CUDAPinnedPlace"
)
py
::
class_
<
paddle
::
platform
::
CUDAPinnedPlace
>
(
m
,
"CUDAPinnedPlace"
)
.
def
(
py
::
init
<>
())
.
def
(
"__init__"
,
[](
platform
::
CUDAPinnedPlace
&
)
{
#ifndef PADDLE_WITH_CUDA
PADDLE_THROW
(
"Cannot use CUDAPinnedPlace in CPU only version"
);
#endif
})
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CUDAPinnedPlace
&>
);
.
def
(
"__str__"
,
string
::
to_string
<
const
platform
::
CUDAPinnedPlace
&>
);
py
::
class_
<
platform
::
Place
>
(
m
,
"Place"
)
py
::
class_
<
platform
::
Place
>
(
m
,
"Place"
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录