CUDA initialization error when making a dataloader from random_split()


(Liangping) #1

I want to break a dataset into two subsets, and eventually one dataloader for each subset. I searched on the forum and found some related posts such as [ Torch.utils.data.dataset.random_split]. I tried random_split(), but still got errors:

train_dataset, test_dataset = torch.utils.data.random_split(fullDataSet, [train_size, test_size])  
training_loader = DataLoader(train_dataset, batch_size = batch_size, shuffle=True, num_workers=8) 
test_loader = DataLoader(test_dataset, batch_size = batch_size, shuffle=True, num_workers=8) 

for j, data in enumerate(training_loader):
    signals, labels = data
    if j%100 == 0: 
        print(labels)

RuntimeError Traceback (most recent call last)
in
----> 1 for j, data in enumerate(training_loader):
2 signals, labels = data
3 if j%100 == 0:
4 print(labels)

RuntimeError: CUDA error: initialization error

Thanks.