You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I set the option --nThreads to 8, but the dataloader seems to not work as expected. I guess that could be duplicate datasets are working with independent attributes in these 8 threads.
I've got all the data_type printed at the beginning of each batch. One type of data is fed successively for nThreads times until it gets increased. Is there any way to fix this without loss of much performance?
I've solved it myself. The optional argument worker_init_fn in DataLoader helps. In specific, instantiate the DataLoader with function of setting the correct data_type as worker_init_fn.
class MyDataset(Dataset):
...
def set_data_type(self, worker_id):
self.data_type = worker_id % 6 # or any other cycle length
...
loader = DataLoader(..., worker_init_fn=dataset.set_data_type)
And the in-worker data_type update step should also be modified to opt.nThreads % 6.
I set the option
--nThreads
to 8, but the dataloader seems to not work as expected. I guess that could be duplicate datasets are working with independent attributes in these 8 threads.I've got all the
data_type
printed at the beginning of each batch. One type of data is fed successively fornThreads
times until it gets increased. Is there any way to fix this without loss of much performance?The text was updated successfully, but these errors were encountered: