Hello, I’m PyTorch beginner, but I want to share my case.
I supposed that a worker is assigned samples as the batch size in multi-thread jobs.
Let’s say,

N: total number of samples in dataloader
B: batch size
C: num_workers

if N = B * C would be appropriate when you determine the number of batch size and workers.
if N < B * C, then some threads didn’t work.
if N > B * C, then all threads works well.
Here is my test case,
I tested using vary batch size and num_workers.
Total number of samples for DataLoader = 127 (N)
Batch size (B), Num workers ©
myDataset = classMyDataSet() # classMyDataLoader is inherited class of “torch.utils.data.DataSet”
myLoader = torch.utils.data.DataLoader(myDataset, batch_size=B, shuffle=False, num_workers=C, pin_memory=True)
bx, by = next(iter(myLoader)) # at this line, dataloader started to work
Case 1. B = 1 and C = 0

Works well with one core
Only 1 sample was processed

Case 2. B = 1~10 and C = 1 ~ 12 (due to my available threads are 12)

Works well with C core
Only B*C samples were processed (i.e., N < B * C case)

Case 3. B = 11 and C = 12

Works well with C core, however a core processed only 7 samples
127 samples (i.e., N) were processed (i.e., N > B * C case)

Case 4. B = 20 and C = 12

Works only 7 cores (6 cores processed 20 samples, and 1 core processed 7 samples), meanwhile 5 cores didn’t work
127 samples (i.e., N) were processed (i.e., N > B * C case)

Case 5. B = 60 and C = 12

Works only 3 cores (2 cores processed 60 samples and 1 core processed 7), meanwhile 9 cores didn’t work
127 samples (i.e., N) were processed (i.e., N > B * C case)

Case 6. B = 127 and C = 12

Only a core processed 127 samples, 11 cores didn’t work
127 samples (i.e., N) were processed at (i.e., N > B * C case)

I have question about this issue.
Intuitively, I expected that the multi-threads work for samples as batch size.
However, it worked B * C samples when I call the batch loader (i.e., at the line “bx, by = next(iter(myLoader))”.
Is there any reason?
Thanks to PyTorch developers and contributors!