python - Proper Usage of PyTorch's non_blocking=True for Data ...
stackoverflow.com › questions › 63460538Aug 18, 2020 · Transferring data to GPU using data = data.cuda (non_blocking=True) Pin data to CPU memory using train_loader = DataLoader (..., pin_memory=True) However, I cannot understand how non-blocking transfer is being performed in this official PyTorch example, specifically this code block: for i, (images, target) in enumerate (train_loader): # measure data loading time data_time.update (time.time () - end) if args.gpu is not None: images = images.cuda (args.gpu, non_blocking=True) if torch.cuda.