Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
Crayon鑫
Paddle
提交
b5a1c146
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看板
未验证
提交
b5a1c146
编写于
6月 13, 2019
作者:
C
chengduo
提交者:
GitHub
6月 13, 2019
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update CPU_NUM config (#18059)
* update CPU_NUM config test=develop
上级
f8ecc3de
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
34 addition
and
13 deletion
+34
-13
paddle/fluid/framework/parallel_executor.cc
paddle/fluid/framework/parallel_executor.cc
+6
-0
python/paddle/dataset/flowers.py
python/paddle/dataset/flowers.py
+1
-2
python/paddle/fluid/contrib/slim/tests/test_graph_wrapper.py
python/paddle/fluid/contrib/slim/tests/test_graph_wrapper.py
+2
-0
python/paddle/fluid/data_feeder.py
python/paddle/fluid/data_feeder.py
+3
-5
python/paddle/fluid/framework.py
python/paddle/fluid/framework.py
+19
-6
python/paddle/fluid/tests/unittests/test_parallel_executor_dry_run.py
...e/fluid/tests/unittests/test_parallel_executor_dry_run.py
+2
-0
python/paddle/fluid/tests/unittests/test_py_reader_using_executor.py
...le/fluid/tests/unittests/test_py_reader_using_executor.py
+1
-0
未找到文件。
paddle/fluid/framework/parallel_executor.cc
浏览文件 @
b5a1c146
...
...
@@ -328,6 +328,12 @@ ParallelExecutor::ParallelExecutor(const std::vector<platform::Place> &places,
"the number of places must be greater than 1."
);
}
LOG
(
WARNING
)
<<
string
::
Sprintf
(
"The number of %s, which is used in ParallelExecutor, is %lu. And "
"the Program will be copied %lu copies"
,
(
member_
->
use_cuda_
?
"CUDAPlace"
:
"CPUPlace"
),
places
.
size
(),
places
.
size
());
// Step 1. Bcast the bcast_vars to devs.
// Create local scopes
if
(
local_scopes
.
empty
())
{
...
...
python/paddle/dataset/flowers.py
浏览文件 @
b5a1c146
...
...
@@ -138,8 +138,7 @@ def reader_creator(data_file,
break
if
use_xmap
:
cpu_num
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
cpu_count
()))
return
xmap_readers
(
mapper
,
reader
,
cpu_num
,
buffered_size
)
return
xmap_readers
(
mapper
,
reader
,
min
(
4
,
cpu_count
()),
buffered_size
)
else
:
return
map_readers
(
mapper
,
reader
)
...
...
python/paddle/fluid/contrib/slim/tests/test_graph_wrapper.py
浏览文件 @
b5a1c146
...
...
@@ -19,6 +19,8 @@ import six
import
numpy
as
np
from
paddle.fluid.contrib.slim.graph
import
GraphWrapper
from
paddle.fluid
import
core
import
os
os
.
environ
[
'CPU_NUM'
]
=
str
(
4
)
def
residual_block
(
num
):
...
...
python/paddle/fluid/data_feeder.py
浏览文件 @
b5a1c146
...
...
@@ -22,7 +22,7 @@ from six.moves import zip, range, xrange
import
multiprocessing
from
.framework
import
Variable
,
default_main_program
,
_current_expected_place
from
.framework
import
_cpu_num
,
_cuda_ids
__all__
=
[
'DataFeeder'
]
...
...
@@ -359,11 +359,9 @@ class DataFeeder(object):
if
num_places
is
not
None
:
return
int
(
num_places
)
elif
isinstance
(
self
.
place
,
core
.
CUDAPlace
):
return
core
.
get_cuda_device_count
(
)
return
len
(
_cuda_ids
()
)
else
:
cpu_num
=
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
multiprocessing
.
cpu_count
()))
return
cpu_num
return
_cpu_num
()
def
decorate_reader
(
self
,
reader
,
...
...
python/paddle/fluid/framework.py
浏览文件 @
b5a1c146
...
...
@@ -82,7 +82,24 @@ def _current_expected_place():
def
_cpu_num
():
return
int
(
os
.
environ
.
get
(
'CPU_NUM'
,
multiprocessing
.
cpu_count
()))
cpu_num
=
os
.
environ
.
get
(
'CPU_NUM'
,
None
)
if
cpu_num
is
None
:
sys
.
stderr
.
write
(
'The CPU_NUM is not specified, you should set CPU_NUM in '
'the environment variable list, i.e export CPU_NUM=1. CPU_NUM '
'indicates that how many CPUPlace are used in the current task.
\n
'
'!!! The default number of CPUPlaces is 1.'
)
os
.
environ
[
'CPU_NUM'
]
=
str
(
1
)
return
int
(
cpu_num
)
def
_cuda_ids
():
gpus_env
=
os
.
getenv
(
"FLAGS_selected_gpus"
)
if
gpus_env
:
device_ids
=
[
int
(
s
)
for
s
in
gpus_env
.
split
(
","
)]
else
:
device_ids
=
six
.
moves
.
range
(
core
.
get_cuda_device_count
())
return
device_ids
def
cuda_places
(
device_ids
=
None
):
...
...
@@ -116,11 +133,7 @@ def cuda_places(device_ids=None):
assert
core
.
is_compiled_with_cuda
(),
\
"Not compiled with CUDA"
if
device_ids
is
None
:
gpus_env
=
os
.
getenv
(
"FLAGS_selected_gpus"
)
if
gpus_env
:
device_ids
=
[
int
(
s
)
for
s
in
gpus_env
.
split
(
","
)]
else
:
device_ids
=
six
.
moves
.
range
(
core
.
get_cuda_device_count
())
device_ids
=
_cuda_ids
()
elif
not
isinstance
(
device_ids
,
(
list
,
tuple
)):
device_ids
=
[
device_ids
]
return
[
core
.
CUDAPlace
(
dev_id
)
for
dev_id
in
device_ids
]
...
...
python/paddle/fluid/tests/unittests/test_parallel_executor_dry_run.py
浏览文件 @
b5a1c146
...
...
@@ -17,6 +17,8 @@ from paddle.fluid import compiler
import
unittest
import
logging
import
six
import
os
os
.
environ
[
'CPU_NUM'
]
=
str
(
4
)
class
TestBase
(
unittest
.
TestCase
):
...
...
python/paddle/fluid/tests/unittests/test_py_reader_using_executor.py
浏览文件 @
b5a1c146
...
...
@@ -22,6 +22,7 @@ import numpy as np
import
threading
import
multiprocessing
import
os
os
.
environ
[
'CPU_NUM'
]
=
str
(
4
)
def
as_tensor
(
np_array_or_tensor
,
place
=
None
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录