Skip to content

Commit

Permalink
[Bug Fixed] use torch.cuda.is_available() (#2661)
Browse files Browse the repository at this point in the history
Co-authored-by: Olatunji Ruwase <[email protected]>
  • Loading branch information
wkcn and tjruwase authored Jan 9, 2023
1 parent 97deaae commit 323c266
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion deepspeed/runtime/fp16/fused_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def __init__(self,
self.deepspeed = deepspeed
self.has_moe_layers = has_moe_layers
self.using_pipeline = self.deepspeed.pipeline_parallelism
if not torch.cuda.is_available:
if not torch.cuda.is_available():
raise SystemError("Cannot use fp16 without CUDA.")
self.optimizer = init_optimizer

Expand Down
2 changes: 1 addition & 1 deletion deepspeed/runtime/fp16/unfused_optimizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self,
if dist.get_rank() == 0:
logger.info(f'Fused Lamb Legacy : {self.fused_lamb_legacy} ')

if not torch.cuda.is_available:
if not torch.cuda.is_available():
raise SystemError("Cannot use fp16 without CUDA.")
self.optimizer = init_optimizer

Expand Down
2 changes: 1 addition & 1 deletion deepspeed/runtime/zero/stage3.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ def __init__(self,
# - assume all params requires grad
# - flat by groups, not keeping state. TODO: remove state explicitly?
# - master grad and unflat master weight never exist. TODO: a way to save out unflat master?
if not torch.cuda.is_available:
if not torch.cuda.is_available():
raise SystemError("Cannot use fp16 without CUDA.")

self.optimizer = init_optimizer
Expand Down
2 changes: 1 addition & 1 deletion deepspeed/runtime/zero/stage_1_and_2.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def __init__(self,
# - assume all params requires grad
# - flat by groups, not keeping state. TODO: remove state explicitly?
# - master grad and unflat master weight never exist. TODO: a way to save out unflat master?
if not torch.cuda.is_available:
if not torch.cuda.is_available():
raise SystemError("Cannot use fp16 without CUDA.")
self.optimizer = init_optimizer

Expand Down

0 comments on commit 323c266

Please sign in to comment.