I’m trying to load images from the GTSRB dataset for image classification training. The data loading works when i set number of workers = 0. However, when I set it to anything more than 0, I get an error. The code is below.
import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
from torch.utils.data import Dataset, DataLoader, sampler
import torchvision
from torchvision import transforms, utils
import torchvision.utils as vutils
import torchvision.datasets as dset
from torch.autograd import Variable

workers = 4
batch_size = 128
image_size = 32
num_epochs = 15
num_classes = 43
num_gpu = 1

trainingClassifierRoot =  '../GTSRB/Final_Training/Images/'
testClassifierRoot = '../GTSRB/Online-Test/'


# Create the dataset
trainClassifierDataset = dset.ImageFolder(root=trainingClassifierRoot,
                           transform=transforms.Compose([
                               transforms.Resize(image_size),
                               transforms.CenterCrop(image_size),
                               transforms.ToTensor(),
                               transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
                           ]))

testClassifierDataset = dset.ImageFolder(root=testClassifierRoot,
                           transform=transforms.Compose([
                               transforms.Resize(image_size),
                               transforms.CenterCrop(image_size),
                               transforms.ToTensor(),
                               transforms.Normalize((0.5, 0.5, 0.5), (0.5, 0.5, 0.5)),
                           ]))

# Create the dataloader
trainClassifierLoader = torch.utils.data.DataLoader(trainClassifierDataset, batch_size=batch_size, shuffle=True, num_workers=workers)
testClassifierLoader = torch.utils.data.DataLoader(testClassifierDataset, batch_size=batch_size, shuffle=True, num_workers=workers)
dataiter = iter(trainClassifierLoader)

And the error I get is below
 File "<ipython-input-28-71c601936f6e>", line 72, in <module>
    dataiter = iter(trainClassifierLoader)

  File "C:\ProgramData\Anaconda3\envs\Python3_5\lib\site-packages\torch\utils\data\dataloader.py", line 501, in __iter__
    return _DataLoaderIter(self)

  File "C:\ProgramData\Anaconda3\envs\Python3_5\lib\site-packages\torch\utils\data\dataloader.py", line 289, in __init__
    w.start()

  File "C:\ProgramData\Anaconda3\envs\Python3_5\lib\multiprocessing\process.py", line 105, in start
    self._popen = self._Popen(self)

  File "C:\ProgramData\Anaconda3\envs\Python3_5\lib\multiprocessing\context.py", line 212, in _Popen
    return _default_context.get_context().Process._Popen(process_obj)

  File "C:\ProgramData\Anaconda3\envs\Python3_5\lib\multiprocessing\context.py", line 313, in _Popen
    return Popen(process_obj)

  File "C:\ProgramData\Anaconda3\envs\Python3_5\lib\multiprocessing\popen_spawn_win32.py", line 34, in __init__
    prep_data = spawn.get_preparation_data(process_obj._name)

  File "C:\ProgramData\Anaconda3\envs\Python3_5\lib\multiprocessing\spawn.py", line 173, in get_preparation_data
    main_mod_name = getattr(main_module.__spec__, "name", None)

AttributeError: module '__main__' has no attribute '__spec__'

Any ideas on what is causing this?