Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
magicwindyyd
mindspore
提交
9cc95567
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看板
提交
9cc95567
编写于
5月 29, 2020
作者:
M
mindspore-ci-bot
提交者:
Gitee
5月 29, 2020
浏览文件
操作
浏览文件
下载
差异文件
!1649 GPU fix example scripts
Merge pull request !1649 from VectorSL/fix-gpu-example-resnet
上级
57874cd6
47a8d3e5
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
4 addition
and
3 deletion
+4
-3
example/resnet50_cifar10/dataset.py
example/resnet50_cifar10/dataset.py
+1
-0
example/resnet50_cifar10/train.py
example/resnet50_cifar10/train.py
+3
-3
未找到文件。
example/resnet50_cifar10/dataset.py
浏览文件 @
9cc95567
...
@@ -42,6 +42,7 @@ def create_dataset(dataset_path, do_train, repeat_num=1, batch_size=32, target="
...
@@ -42,6 +42,7 @@ def create_dataset(dataset_path, do_train, repeat_num=1, batch_size=32, target="
device_num
=
int
(
os
.
getenv
(
"DEVICE_NUM"
))
device_num
=
int
(
os
.
getenv
(
"DEVICE_NUM"
))
rank_id
=
int
(
os
.
getenv
(
"RANK_ID"
))
rank_id
=
int
(
os
.
getenv
(
"RANK_ID"
))
else
:
else
:
init
(
"nccl"
)
rank_id
=
get_rank
()
rank_id
=
get_rank
()
device_num
=
get_group_size
()
device_num
=
get_group_size
()
...
...
example/resnet50_cifar10/train.py
浏览文件 @
9cc95567
...
@@ -53,15 +53,12 @@ if __name__ == '__main__':
...
@@ -53,15 +53,12 @@ if __name__ == '__main__':
mirror_mean
=
True
)
mirror_mean
=
True
)
auto_parallel_context
().
set_all_reduce_fusion_split_indices
([
107
,
160
])
auto_parallel_context
().
set_all_reduce_fusion_split_indices
([
107
,
160
])
ckpt_save_dir
=
config
.
save_checkpoint_path
ckpt_save_dir
=
config
.
save_checkpoint_path
loss
=
SoftmaxCrossEntropyWithLogits
(
sparse
=
True
,
reduction
=
'mean'
)
elif
target
==
"GPU"
:
elif
target
==
"GPU"
:
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"GPU"
,
save_graphs
=
False
)
context
.
set_context
(
mode
=
context
.
GRAPH_MODE
,
device_target
=
"GPU"
,
save_graphs
=
False
)
init
(
"nccl"
)
init
(
"nccl"
)
context
.
set_auto_parallel_context
(
device_num
=
get_group_size
(),
parallel_mode
=
ParallelMode
.
DATA_PARALLEL
,
context
.
set_auto_parallel_context
(
device_num
=
get_group_size
(),
parallel_mode
=
ParallelMode
.
DATA_PARALLEL
,
mirror_mean
=
True
)
mirror_mean
=
True
)
ckpt_save_dir
=
config
.
save_checkpoint_path
+
"ckpt_"
+
str
(
get_rank
())
+
"/"
ckpt_save_dir
=
config
.
save_checkpoint_path
+
"ckpt_"
+
str
(
get_rank
())
+
"/"
loss
=
SoftmaxCrossEntropyWithLogits
(
sparse
=
True
,
is_grad
=
False
,
reduction
=
'mean'
)
epoch_size
=
config
.
epoch_size
epoch_size
=
config
.
epoch_size
net
=
resnet50
(
class_num
=
config
.
class_num
)
net
=
resnet50
(
class_num
=
config
.
class_num
)
...
@@ -77,8 +74,11 @@ if __name__ == '__main__':
...
@@ -77,8 +74,11 @@ if __name__ == '__main__':
opt
=
Momentum
(
filter
(
lambda
x
:
x
.
requires_grad
,
net
.
get_parameters
()),
lr
,
config
.
momentum
,
opt
=
Momentum
(
filter
(
lambda
x
:
x
.
requires_grad
,
net
.
get_parameters
()),
lr
,
config
.
momentum
,
config
.
weight_decay
,
config
.
loss_scale
)
config
.
weight_decay
,
config
.
loss_scale
)
if
target
==
'GPU'
:
if
target
==
'GPU'
:
loss
=
SoftmaxCrossEntropyWithLogits
(
sparse
=
True
,
is_grad
=
False
,
reduction
=
'mean'
)
opt
=
Momentum
(
filter
(
lambda
x
:
x
.
requires_grad
,
net
.
get_parameters
()),
lr
,
config
.
momentum
)
model
=
Model
(
net
,
loss_fn
=
loss
,
optimizer
=
opt
,
metrics
=
{
'acc'
})
model
=
Model
(
net
,
loss_fn
=
loss
,
optimizer
=
opt
,
metrics
=
{
'acc'
})
else
:
else
:
loss
=
SoftmaxCrossEntropyWithLogits
(
sparse
=
True
,
reduction
=
'mean'
)
model
=
Model
(
net
,
loss_fn
=
loss
,
optimizer
=
opt
,
loss_scale_manager
=
loss_scale
,
metrics
=
{
'acc'
},
model
=
Model
(
net
,
loss_fn
=
loss
,
optimizer
=
opt
,
loss_scale_manager
=
loss_scale
,
metrics
=
{
'acc'
},
amp_level
=
"O2"
,
keep_batchnorm_fp32
=
True
)
amp_level
=
"O2"
,
keep_batchnorm_fp32
=
True
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录