Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,7 @@ def evaluate(args):
},
additional_metrics={"val_acc": Accuracy(output_transform=from_engine(["pred", "label"]), device=device)},
val_handlers=val_handlers,
# if no FP16 support in GPU or PyTorch version < 1.6, will not enable AMP evaluation
amp=True if monai.utils.get_torch_version_tuple() >= (1, 6) else False,
amp=True,
)
evaluator.run()
dist.destroy_process_group()
Expand Down
3 changes: 1 addition & 2 deletions acceleration/distributed_training/unet_training_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,8 +177,7 @@ def train(args):
optimizer=opt,
loss_function=loss,
inferer=SimpleInferer(),
# if no FP16 support in GPU or PyTorch version < 1.6, will not enable AMP evaluation
amp=True if monai.utils.get_torch_version_tuple() >= (1, 6) else False,
amp=True,
postprocessing=train_post_transforms,
key_train_metric={"train_acc": Accuracy(output_transform=from_engine(["pred", "label"]), device=device)},
train_handlers=train_handlers,
Expand Down
3 changes: 1 addition & 2 deletions modules/engines/unet_evaluation_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,7 @@ def main(tempdir):
},
additional_metrics={"val_acc": Accuracy(output_transform=from_engine(["pred", "label"]))},
val_handlers=val_handlers,
# if no FP16 support in GPU or PyTorch version < 1.6, will not enable AMP evaluation
amp=True if monai.utils.get_torch_version_tuple() >= (1, 6) else False,
amp=True,
)
evaluator.run()

Expand Down
5 changes: 2 additions & 3 deletions modules/engines/unet_training_dict.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,7 @@ def main(tempdir):
},
additional_metrics={"val_acc": Accuracy(output_transform=from_engine(["pred", "label"]))},
val_handlers=val_handlers,
# if no FP16 support in GPU or PyTorch version < 1.6, will not enable AMP evaluation
amp=True if monai.utils.get_torch_version_tuple() >= (1, 6) else False,
amp=True,
)

train_post_transforms = Compose(
Expand Down Expand Up @@ -182,7 +181,7 @@ def main(tempdir):
key_train_metric={"train_acc": Accuracy(output_transform=from_engine(["pred", "label"]))},
train_handlers=train_handlers,
# if no FP16 support in GPU or PyTorch version < 1.6, will not enable AMP training
amp=True if monai.utils.get_torch_version_tuple() >= (1, 6) else False,
amp=True,
)
# set initialized trainer for "early stop" handlers
val_handlers[0].set_trainer(trainer=trainer)
Expand Down
6 changes: 0 additions & 6 deletions pathology/tumor_detection/ignite/camelyon_train_evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,6 @@ def train(cfg):
else:
optimizer = SGD(model.parameters(), lr=cfg["lr"], momentum=0.9)

# AMP scaler
if cfg["amp"]:
cfg["amp"] = True if monai.utils.get_torch_version_tuple() >= (1, 6) else False
else:
cfg["amp"] = False

scheduler = lr_scheduler.CosineAnnealingLR(optimizer, T_max=cfg["n_epochs"])

# --------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,12 +187,6 @@ def train(cfg):
else:
optimizer = SGD(model.parameters(), lr=cfg["lr"], momentum=0.9)

# AMP scaler
if cfg["amp"]:
cfg["amp"] = True if monai.utils.get_torch_version_tuple() >= (1, 6) else False
else:
cfg["amp"] = False

scheduler = lr_scheduler.CosineAnnealingLR(optimizer, T_max=cfg["n_epochs"])

# --------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,6 @@ def main(cfg):
optimizer = SGD(model.parameters(), lr=cfg["lr"], momentum=0.9)

# AMP scaler
cfg["amp"] = cfg["amp"] and monai.utils.get_torch_version_tuple() >= (1, 6)
if cfg["amp"] is True:
scaler = GradScaler()
else:
Expand Down
1 change: 0 additions & 1 deletion performance_profiling/pathology/train_evaluate_nvtx.py
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,6 @@ def main(cfg):
optimizer = SGD(model.parameters(), lr=cfg["lr"], momentum=0.9)

# AMP scaler
cfg["amp"] = cfg["amp"] and monai.utils.get_torch_version_tuple() >= (1, 6)
if cfg["amp"] is True:
scaler = GradScaler()
else:
Expand Down