Iterator doesn't work with DataLoader on GPU
I'm using PyTorch on Google Colab, I'm getting this error when Using GPU,
TypeError                                 Traceback (most recent call last)
&lt;ipython-input-33-41cdbc758ecd&gt; in &lt;module&gt;()
----&gt; 1 dataiter= iter(trainloader)

TypeError: '_SingleProcessDataLoaderIter' object is not callable

but wen using normal CPU there is no Error.
My code:
%matplotlib inline
%config InlineBackend.figure_format = 'retina'

import torch
import numpy as np
from torchvision import datasets, transforms

from collections import  OrderedDict

from torch import nn
from torch import  optim
import torch.nn.functional as F
import helper


transform = transforms.Compose([transforms.ToTensor(),
     transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5))])

trainset= datasets.MNIST(&quot;MINIST_data/&quot;, download= True, train=True, transform=transform)
trainloader= torch.utils.data.DataLoader(trainset, batch_size= 64, shuffle=True)
dataiter= iter(trainloader)

Using enumerate instead of iter works with GPU but I don't know why, can someone explain the error to me and why it is happening !?

You don't have to use iter. trainloader is already iterable. The loop should be done like this for data in trainloader: or for index, data in enumerate(trainloader):
