Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Efficientnet on xpu #155

Merged
merged 31 commits into from
Jul 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 13 additions & 10 deletions training/benchmarks/efficientnet/pytorch/train/trainer_adapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,17 +88,20 @@ def create_grad_scaler(args):

def backward(args, step: int, epoch: int, loss: torch.Tensor, model: nn.Module,
optimizer: Optimizer, scaler):
optimizer.zero_grad()
if scaler is not None:
scaler.scale(loss).backward()
if args.clip_grad_norm is not None:
# we should unscale the gradients of optimizer's assigned params if do gradient clipping
scaler.unscale_(optimizer)
nn.utils.clip_grad_norm_(model.parameters(), args.clip_grad_norm)
scaler.step(optimizer)
scaler.update()
if step % args.gradient_accumulation_steps == 0:
if args.clip_grad_norm is not None:
# we should unscale the gradients of optimizer's assigned params if do gradient clipping
scaler.unscale_(optimizer)
nn.utils.clip_grad_norm_(model.parameters(), args.clip_grad_norm)
scaler.step(optimizer)
optimizer.zero_grad()
scaler.update()
else:
loss.backward()
if args.clip_grad_norm is not None:
nn.utils.clip_grad_norm_(model.parameters(), args.clip_grad_norm)
optimizer.step()
if step % args.gradient_accumulation_steps == 0:
if args.clip_grad_norm is not None:
nn.utils.clip_grad_norm_(model.parameters(), args.clip_grad_norm)
optimizer.step()
optimizer.zero_grad()
7 changes: 5 additions & 2 deletions training/kunlunxin/efficientnet-pytorch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,17 @@


### 运行情况
| 训练资源 | 配置文件 | 运行时长(s) | 目标精度 | 收敛精度 | Steps数 | 性能samples/s) |
| 训练资源 | 配置文件 | 运行时长(s) | 目标精度 | 收敛精度 | Steps数 | 性能 (samples/s)|
| -------- | --------------- | ----------- | -------- | -------- | ------- | ---------------- |
| 单机1卡 | config_R300x1x1 | | | | | |
| 单机2卡 | config_R300x1x2 | | | | | |
| 单机4卡 | config_R300x1x4 | | | | | |
| 单机8卡 | config_R300x1x8 | | | | | |
| 单机8卡 | config_R300x1x8 | | 82.672 | 72.666 | 868540 | |
| 两机8卡 | config_R300x2x8 | | | | | |

### 收敛曲线
![acc](acc.png)

### 许可证

Apache 2.0 license。
Binary file added training/kunlunxin/efficientnet-pytorch/acc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from config_common import *

train_batch_size = 64
eval_batch_size = 64
eval_batch_size = 128
gradient_accumulation_steps = 2