ptrblck
February 24, 2022, 6:41am
43
Did you forget to add the if-clause protection as explained in the error message?
If so, did its usage fix the error?
Here is a small example:
import torch
def main()
for i, data in enumerate(dataloader):
# do something here
if __name__ == '__main__':
main()
lanka
(lankanatha)
February 24, 2022, 8:25am
44
yes, i have added it also…now im getting different OS Error
OSError: [WinError 1455] The paging file is too small for this operation to complete. Error loading "C:\Users\test\Anaconda3\envs\py36\lib\site-packages\torch\lib\caffe2_detectron_ops_gpu.dll" or one of its dependencies.
class ConcatDataset(Dataset):
def __init__(self,dataset_list, probs=None):
self.datasets = dataset_list
self.probs = probs if probs else [1/len(self.datasets)] * len(self.datasets)
def __getitem__(self, i):
chosen_dataset = np.random.choice(self.datasets, 1, p=self.probs)[0]
i = i % len(chosen_dataset)
return chosen_dataset[i]
def __len__(self):
return max(len(d) for d in self.datasets)
adaxi827
(阿达西)
January 11, 2023, 4:52pm
46
Maybe you can try to set the random seed before each iteration
def setup_seed(seed):
torch.manual_seed(seed)
torch.cuda.manual_seed_all(seed)
np.random.seed(seed)
random.seed(seed)
torch.backends.cudnn.deterministic = True
setup_seed(123)
inputs1, target1 = next(iter(train_dl1))
setup_seed(123)
inputs2, targets2 = next(iter(train_dl2))