Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
24ff160f
M
mindspore
项目概览
magicwindyyd
/
mindspore
与 Fork 源项目一致
Fork自
MindSpore / mindspore
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
M
mindspore
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
24ff160f
编写于
4月 28, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
4月 28, 2020
浏览文件
操作
浏览文件
下载
差异文件
!817 remove amp setting and add RANK_TABLE_FILE
Merge pull request !817 from wandongdong/r0.2
上级
e3fcf825
1465afc5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
13 addition
and
21 deletion
+13
-21
example/mobilenetv2_imagenet2012/launch.py
example/mobilenetv2_imagenet2012/launch.py
+12
-19
example/mobilenetv2_imagenet2012/train.py
example/mobilenetv2_imagenet2012/train.py
+1
-2
未找到文件。
example/mobilenetv2_imagenet2012/launch.py
浏览文件 @
24ff160f
...
...
@@ -15,7 +15,6 @@
"""launch train script"""
import
os
import
sys
import
subprocess
import
json
from
argparse
import
ArgumentParser
...
...
@@ -125,25 +124,19 @@ def main():
sys
.
stdout
.
flush
()
# spawn the processes
current_env
=
os
.
environ
.
copy
()
current_env
[
"RANK_SIZE"
]
=
str
(
args
.
nproc_per_node
)
if
args
.
nproc_per_node
>
1
:
current_env
[
"MINDSPORE_HCCL_CONFIG_PATH"
]
=
table_fn
processes
=
[]
cmds
=
[]
for
rank_id
in
range
(
0
,
args
.
nproc_per_node
):
current_env
[
"RANK_ID"
]
=
str
(
rank_id
)
current_env
[
"DEVICE_ID"
]
=
visible_devices
[
rank_id
]
cmd
=
[
sys
.
executable
,
"-u"
]
cmd
.
append
(
args
.
training_script
)
cmd
.
extend
(
args
.
training_script_args
)
process
=
subprocess
.
Popen
(
cmd
,
env
=
current_env
)
processes
.
append
(
process
)
cmds
.
append
(
cmd
)
for
process
,
cmd
in
zip
(
processes
,
cmds
):
process
.
wait
(
)
if
process
.
returncode
!=
0
:
raise
subprocess
.
CalledProcessError
(
returncode
=
process
.
returncode
,
cmd
=
cmd
)
device_id
=
visible_devices
[
rank_id
]
device_dir
=
os
.
path
.
join
(
os
.
getcwd
(),
'device{}'
.
format
(
rank_id
))
rank_process
=
'export RANK_SIZE={} && export RANK_ID={} && export DEVICE_ID={} && '
.
format
(
args
.
nproc_per_node
,
rank_id
,
device_id
)
if
args
.
nproc_per_node
>
1
:
rank_process
+=
'export MINDSPORE_HCCL_CONFIG_PATH={} && '
.
format
(
table_fn
)
rank_process
+=
'export RANK_TABLE_FILE={} && '
.
format
(
table_fn
)
rank_process
+=
'rm -rf {dir} && mkdir {dir} && cd {dir} && python {script} '
.
format
(
dir
=
device_dir
,
script
=
args
.
training_script
)
rank_process
+=
' '
.
join
(
args
.
training_script_args
)
+
' > log{}.log 2>&1 &'
.
format
(
rank_id
)
os
.
system
(
rank_process
)
if
__name__
==
"__main__"
:
...
...
example/mobilenetv2_imagenet2012/train.py
浏览文件 @
24ff160f
...
...
@@ -135,8 +135,7 @@ if __name__ == '__main__':
opt
=
Momentum
(
filter
(
lambda
x
:
x
.
requires_grad
,
net
.
get_parameters
()),
lr
,
config
.
momentum
,
config
.
weight_decay
,
config
.
loss_scale
)
model
=
Model
(
net
,
loss_fn
=
loss
,
optimizer
=
opt
,
loss_scale_manager
=
loss_scale
,
amp_level
=
'O0'
,
keep_batchnorm_fp32
=
False
)
model
=
Model
(
net
,
loss_fn
=
loss
,
optimizer
=
opt
,
loss_scale_manager
=
loss_scale
)
cb
=
None
if
rank_id
==
0
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录