VSCode bug with PyTorch DataLoader?
The following code example works in Python, but fails in VSCode in Linux (but not VSCode in Windows).  I am wondering if there is something wrong with my code, or if there is something wrong with VSCode under Linux?

#Test of PyTorch DataLoader and Visual Studio Code
from torch.utils.data import Dataset, DataLoader

class SimpleData(Dataset):
    """Very simple dataset"""
    def __init__(self):
        self.data = range(20)
    def __len__(self):
        return len(self.data)
    def __getitem__(self, idx):
        return self.data[idx]

if __name__ == '__main__':

    #Initialize DataLoader with above Dataset:
    dataloader = DataLoader(SimpleData(), batch_size=4, num_workers=1)

    print('Using DataLoader to show data in batches: ')
    for i, sample_batch in enumerate(dataloader):    #This fails in VSCode in Linux
        print('batch ', i, ':', sample_batch)

    print("--- Done ---")


The expected output is:

Using DataLoader to show data in batches:
batch  0 : tensor([0, 1, 2, 3])
batch  1 : tensor([4, 5, 6, 7])
batch  2 : tensor([ 8,  9, 10, 11])
batch  3 : tensor([12, 13, 14, 15])
batch  4 : tensor([16, 17, 18, 19])
--- Done ---


But with VSCode in Linux it hangs after printing the first line.

Have you tried with num_workers=0?

May be VS Code is not able to spawn a new process properly on linux.
