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 []. I tried random_split(), but still got errors:

train_dataset, test_dataset =, [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: 

RuntimeError Traceback (most recent call last)
----> 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