Skip to content

Commit 78186fd

Browse files
author
Quentin Anthony
committed
Fixed bug. Move dataset to GPU for distributed training
1 parent d5fc6b5 commit 78186fd

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

imagenet/main.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -290,7 +290,7 @@ def train(train_loader, model, criterion, optimizer, epoch, args):
290290
# measure data loading time
291291
data_time.update(time.time() - end)
292292

293-
if args.gpu is not None:
293+
if torch.cuda.is_available():
294294
images = images.cuda(args.gpu, non_blocking=True)
295295
if torch.cuda.is_available():
296296
target = target.cuda(args.gpu, non_blocking=True)
@@ -334,7 +334,7 @@ def validate(val_loader, model, criterion, args):
334334
with torch.no_grad():
335335
end = time.time()
336336
for i, (images, target) in enumerate(val_loader):
337-
if args.gpu is not None:
337+
if torch.cuda.is_available():
338338
images = images.cuda(args.gpu, non_blocking=True)
339339
if torch.cuda.is_available():
340340
target = target.cuda(args.gpu, non_blocking=True)

0 commit comments

Comments
 (0)