Hi Ptrblck,
I’m trying to activate the num_workers statement with a custom dataloader. I get the same error as above and I am confused as to where i insert if __name__ == '__main__': into the code.
If i place it thus:
if __name__ == '__main__':

    dataload=dataset3D(csv_file, data_dir,transform=None)

    dataloader = torch.utils.data.DataLoader(dataload, batch_size=20,
                                                shuffle=True, num_workers=4)

for epoch in range(num_epochs):
    for i,data in enumerate(dataloader):


I get the error message:
    for i,data in enumerate(dataloader):
NameError: name 'dataloader' is not defined

so do i have place it inside:
class dataset3D(Dataset):
    def __init__(self,csv_file,data_dir,transform=None):

        self.file_list=pd.read_csv(csv_file, header=None)
        self.data_dir=data_dir
        self.transform=transform
  def __len__(self):

  def __getitem__(self, index): 

*etc*

I have created a def train() then called:
if __name__ == '__main__':
  train()

however this causes the code to run a bit “lumpy-bumpy” & increase the GPU memoray requirements by 40% as the multi processing code is being appled to the model as well as the dataloader, is there a way which i can apply multi processing to the dataloader only?
cheers,
chaslie