File tree Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Expand file tree Collapse file tree 2 files changed +4
-4
lines changed Original file line number Diff line number Diff line change @@ -113,8 +113,8 @@ def __init__(
113
113
)
114
114
else :
115
115
self .random_erasing = None
116
- self .is_cuda = torch . cuda . is_available () and device .type == 'cuda'
117
- self .is_npu = torch . npu . is_available () and device .type == 'npu'
116
+ self .is_cuda = device .type == 'cuda' and torch . cuda . is_available ()
117
+ self .is_npu = device .type == 'npu' and torch . npu . is_available ()
118
118
119
119
def __iter__ (self ):
120
120
first = True
Original file line number Diff line number Diff line change @@ -395,9 +395,9 @@ def _try_run(args, initial_batch_size):
395
395
while batch_size :
396
396
args .batch_size = batch_size * args .num_gpu # multiply by num-gpu for DataParallel case
397
397
try :
398
- if torch . cuda . is_available () and 'cuda' in args .device :
398
+ if 'cuda' in args .device and torch . cuda . is_available () :
399
399
torch .cuda .empty_cache ()
400
- elif torch . npu . is_available () and "npu" in args .device :
400
+ elif "npu" in args .device and torch . npu . is_available () :
401
401
torch .npu .empty_cache ()
402
402
results = validate (args )
403
403
return results
You can’t perform that action at this time.
0 commit comments