Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
BaiXuePrincess
Paddle
提交
770501b8
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看板
未验证
提交
770501b8
编写于
10月 13, 2022
作者:
L
Leo Chen
提交者:
GitHub
10月 13, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add thread name for dataloader (#46990)
上级
f856fc8d
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
11 addition
and
1 deletion
+11
-1
paddle/fluid/platform/os_info.cc
paddle/fluid/platform/os_info.cc
+2
-0
paddle/fluid/platform/os_info.h
paddle/fluid/platform/os_info.h
+1
-1
paddle/fluid/pybind/pybind.cc
paddle/fluid/pybind/pybind.cc
+2
-0
python/paddle/fluid/dataloader/dataloader_iter.py
python/paddle/fluid/dataloader/dataloader_iter.py
+2
-0
python/paddle/fluid/layers/io.py
python/paddle/fluid/layers/io.py
+1
-0
python/paddle/fluid/reader.py
python/paddle/fluid/reader.py
+3
-0
未找到文件。
paddle/fluid/platform/os_info.cc
浏览文件 @
770501b8
...
...
@@ -27,6 +27,7 @@ limitations under the License. */
#else
#include <unistd.h>
#endif
#include "glog/logging.h"
#include "paddle/fluid/framework/new_executor/workqueue/thread_data_registry.h"
#include "paddle/fluid/platform/macros.h" // import DISABLE_COPY_AND_ASSIGN
...
...
@@ -115,6 +116,7 @@ bool SetCurrentThreadName(const std::string& name) {
return
false
;
}
instance
.
SetCurrentThreadData
(
name
);
VLOG
(
4
)
<<
__func__
<<
" "
<<
name
;
return
true
;
}
...
...
paddle/fluid/platform/os_info.h
浏览文件 @
770501b8
...
...
@@ -57,7 +57,7 @@ ThreadId GetCurrentThreadId();
// create/destory when using it.
std
::
unordered_map
<
uint64_t
,
ThreadId
>
GetAllThreadIds
();
static
constexpr
const
char
*
kDefaultThreadName
=
"un
set
"
;
static
constexpr
const
char
*
kDefaultThreadName
=
"un
named
"
;
// Returns kDefaultThreadName if SetCurrentThreadName is never called.
std
::
string
GetCurrentThreadName
();
...
...
paddle/fluid/pybind/pybind.cc
浏览文件 @
770501b8
...
...
@@ -854,6 +854,8 @@ PYBIND11_MODULE(libpaddle, m) {
m
.
def
(
"_set_paddle_lib_path"
,
&
paddle
::
platform
::
dynload
::
SetPaddleLibPath
);
m
.
def
(
"set_current_thread_name"
,
&
paddle
::
platform
::
SetCurrentThreadName
);
m
.
def
(
"_promote_types_if_complex_exists"
,
&
paddle
::
framework
::
PromoteTypesIfComplexExists
);
...
...
python/paddle/fluid/dataloader/dataloader_iter.py
浏览文件 @
770501b8
...
...
@@ -205,6 +205,7 @@ class _DataLoaderIterSingleProcess(_DataLoaderIterBase):
# If we do not set cudaDeviceId in new thread, the default cudaDeviceId will be 0,
# Which may cost hundreds of MB of GPU memory on CUDAPlace(0) if calling some cuda
# APIs in this thread.
core
.
set_current_thread_name
(
"Dataloader_"
+
str
(
id
(
self
)))
_set_expected_place
(
legacy_expected_place
)
while
not
self
.
_thread_done_event
.
is_set
():
...
...
@@ -530,6 +531,7 @@ class _DataLoaderIterMultiProcess(_DataLoaderIterBase):
# If we do not set cudaDeviceId in new thread, the default cudaDeviceId will be 0,
# Which may cost hundreds of MB of GPU memory on CUDAPlace(0) if calling some cuda
# APIs in this thread.
core
.
set_current_thread_name
(
"Dataloader_"
+
str
(
id
(
self
)))
_set_expected_place
(
legacy_expected_place
)
while
not
self
.
_thread_done_event
.
is_set
():
...
...
python/paddle/fluid/layers/io.py
浏览文件 @
770501b8
...
...
@@ -477,6 +477,7 @@ def _py_reader(capacity,
def
__provider_thread__
(
legacy_expected_place
):
try
:
# See _DataLoaderIterSingleProcess._thread_loop() for why set expected place here.
_set_expected_place
(
legacy_expected_place
)
for
tensors
in
func
():
...
...
python/paddle/fluid/reader.py
浏览文件 @
770501b8
...
...
@@ -1126,6 +1126,7 @@ class DygraphGeneratorLoader(DataLoaderBase):
def
_reader_thread_loop_for_multiprocess
(
self
,
legacy_expected_place
):
# See _DataLoaderIterSingleProcess._thread_loop() for why set expected place here.
core
.
set_current_thread_name
(
"Dataloader_"
+
str
(
id
(
self
)))
_set_expected_place
(
legacy_expected_place
)
while
not
self
.
_thread_done_event
.
is_set
():
...
...
@@ -1169,6 +1170,7 @@ class DygraphGeneratorLoader(DataLoaderBase):
def
_reader_thread_loop_for_singleprocess
(
self
,
legacy_expected_place
):
try
:
# See _DataLoaderIterSingleProcess._thread_loop() for why set expected place here.
core
.
set_current_thread_name
(
"Dataloader_"
+
str
(
id
(
self
)))
_set_expected_place
(
legacy_expected_place
)
for
sample
in
self
.
_batch_reader
():
...
...
@@ -1419,6 +1421,7 @@ class GeneratorLoader(DataLoaderBase):
def
__thread_main__
(
legacy_expected_place
):
try
:
# See _DataLoaderIterSingleProcess._thread_loop() for why set expected place here.
core
.
set_current_thread_name
(
"Dataloader_"
+
str
(
id
(
self
)))
_set_expected_place
(
legacy_expected_place
)
while
not
self
.
_queue
.
wait_for_inited
(
1
):
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录