Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
PaddlePaddle
Paddle
提交
7f39bcd1
P
Paddle
项目概览
PaddlePaddle
/
Paddle
大约 1 年 前同步成功
通知
2298
Star
20931
Fork
5422
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1423
列表
看板
标记
里程碑
合并请求
543
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
P
Paddle
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1,423
Issue
1,423
列表
看板
标记
里程碑
合并请求
543
合并请求
543
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
未验证
提交
7f39bcd1
编写于
5月 10, 2023
作者:
C
Chitsing KUI
提交者:
GitHub
5月 10, 2023
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[LAUNCH] add log overwrite flag (#53608)
* add log overwrite flag * use strtobool
上级
0f319f8a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
19 addition
and
7 deletion
+19
-7
python/paddle/distributed/launch/context/args_envs.py
python/paddle/distributed/launch/context/args_envs.py
+10
-1
python/paddle/distributed/launch/controllers/controller.py
python/paddle/distributed/launch/controllers/controller.py
+2
-1
python/paddle/distributed/launch/job/container.py
python/paddle/distributed/launch/job/container.py
+7
-5
未找到文件。
python/paddle/distributed/launch/context/args_envs.py
浏览文件 @
7f39bcd1
...
...
@@ -14,6 +14,7 @@
import
os
from
argparse
import
REMAINDER
,
ArgumentParser
from
distutils.util
import
strtobool
env_args_mapping
=
{
'POD_IP'
:
'host'
,
...
...
@@ -22,6 +23,7 @@ env_args_mapping = {
'PADDLE_NNODES'
:
'nnodes'
,
'PADDLE_RUN_MODE'
:
'run_mode'
,
'PADDLE_LOG_LEVEL'
:
'log_level'
,
'PADDLE_LOG_OVERWRITE'
:
'log_overwrite'
,
'PADDLE_NPROC_PER_NODE'
:
'nproc_per_node'
,
'PADDLE_JOB_ID'
:
'job_id'
,
'PADDLE_RANK'
:
'rank'
,
...
...
@@ -61,7 +63,7 @@ def parse_args():
)
base_group
.
add_argument
(
"--legacy"
,
type
=
bool
,
default
=
False
,
help
=
"use legacy launch"
"--legacy"
,
type
=
strto
bool
,
default
=
False
,
help
=
"use legacy launch"
)
base_group
.
add_argument
(
...
...
@@ -72,6 +74,13 @@ def parse_args():
"--log_level"
,
type
=
str
,
default
=
"INFO"
,
help
=
"log level. Default INFO"
)
base_group
.
add_argument
(
"--log_overwrite"
,
type
=
strtobool
,
default
=
False
,
help
=
"overwrite exits logfiles. Default False"
,
)
base_group
.
add_argument
(
"--nnodes"
,
type
=
str
,
...
...
python/paddle/distributed/launch/controllers/controller.py
浏览文件 @
7f39bcd1
...
...
@@ -205,6 +205,7 @@ class Controller(ControllerBase):
c
=
Container
(
entrypoint
=
(
entrypoint
or
self
.
_get_entrypoint
()),
env
=
(
self
.
ctx
.
get_envs
()
if
use_ctx_env
else
{}),
overwrite_log
=
self
.
ctx
.
args
.
log_overwrite
,
)
c
.
outfile
,
c
.
errfile
=
self
.
_get_out_err_file
(
out
,
err
)
c
.
update_env
(
envs
)
...
...
@@ -286,7 +287,7 @@ class Controller(ControllerBase):
)
try
:
os
.
makedirs
(
os
.
path
.
dirname
(
f
),
exist_ok
=
True
)
with
open
(
f
,
'w'
)
as
fd
:
with
open
(
f
,
container
.
log_mode
)
as
fd
:
for
k
,
v
in
sorted
(
container
.
env
.
items
()):
fd
.
write
(
str
(
f
"
{
k
}
=
{
v
}
\n
"
))
except
Exception
as
e
:
...
...
python/paddle/distributed/launch/job/container.py
浏览文件 @
7f39bcd1
...
...
@@ -25,7 +25,7 @@ class Container:
TODO(kuizhiqing) A container can be run by process/thread or just a callable function
'''
def
__init__
(
self
,
entrypoint
=
[],
rank
=-
1
,
env
=
{}):
def
__init__
(
self
,
entrypoint
=
[],
rank
=-
1
,
env
=
{}
,
overwrite_log
=
False
):
self
.
_entrypoint
=
entrypoint
self
.
_rank
=
rank
self
.
_out
=
None
...
...
@@ -39,6 +39,8 @@ class Container:
self
.
_log_handler
=
None
self
.
_shell
=
False
self
.
log_mode
=
'w'
if
overwrite_log
else
'a'
@
property
def
env
(
self
):
return
self
.
_env
...
...
@@ -104,7 +106,7 @@ class Container:
d
=
os
.
path
.
dirname
(
pth
)
if
not
os
.
path
.
isdir
(
d
):
os
.
makedirs
(
d
,
exist_ok
=
True
)
return
open
(
pth
,
'a'
)
return
open
(
pth
,
self
.
log_mode
)
except
:
return
None
...
...
@@ -120,7 +122,7 @@ class Container:
elif
self
.
_err
:
self
.
_stderr
=
self
.
_get_fd
(
self
.
_err
)
or
sys
.
stderr
if
not
self
.
_log_handler
:
if
self
.
_out
and
not
self
.
_log_handler
:
self
.
_log_handler
=
open
(
self
.
_out
)
self
.
_log_handler
.
seek
(
0
,
2
)
self
.
_log_start_offset
=
self
.
_log_handler
.
tell
()
...
...
@@ -179,7 +181,7 @@ class Container:
def
logs
(
self
,
fn
=
None
,
offset
=
0
,
whence
=
1
,
limit
=
1000
):
if
not
self
.
_log_handler
:
self
.
_log_handler
=
open
(
self
.
_out
)
return
if
fn
is
None
:
fn
=
sys
.
stdout
...
...
@@ -201,7 +203,7 @@ class Container:
def
tail
(
self
,
length
=
3000
):
if
not
self
.
_log_handler
:
self
.
_log_handler
=
open
(
self
.
_out
)
return
try
:
self
.
_log_handler
.
seek
(
0
,
2
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录