-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No works on GPU #4
Comments
me too |
I trained on GPU. Let check your gpu configuration. My code will automatically detect if gpu is available and if yes, the model will be trained on gpu |
Doesn't run on GPU for me as well, only CPU. The model and the tensors return is_cuda=True, still the GPU load is close to 0% and CPU load is 100%. |
I found the reason why GPU load is so low that the dataloader processes data so slowly and GPU is always waiting. |
can you share your found ? I've been troubled by this problem too, the model and the tensors return is_cuda=True, still the GPU load is 0%. |
i have set num_workers=8 and pin_memory=true in dataloader, but it doesn't work ,still the GPU load is 0% |
you can try this: rewrite the __getitem__ function in dataset.py and just for getting items, not process data, and move the process operation to preprocess functions such as word segmentation, word encoding and so on. I recommend that you can use the parameter 'collate_fn' in Dataloader and do some necessary operations like padding. My code put on below for reference.
class MyData(data.Dataset):
def __init__(self, root, state='train'):
self.root = root
with open(root, 'rb') as f:
[self.train_x, self.train_y,
self.val_x, self.val_y,
self.test_x, self.test_y,
self.word2index, self.label2index,
self.n_words, self.n_labels,
# self.train_sq_len, self.test_sq_len
] = pickle.load(f)
if state is 'train':
self.feature = self.train_x[:]
self.label = self.train_y[:]
elif state is 'test':
self.feature = self.test_x
self.label = self.test_y
else:
self.feature = self.val_x
self.label = self.val_y
def __getitem__(self, item):
feature = self.feature[item]
label = self.label[item]
return feature, label
def __len__(self):
return len(self.feature)
def collate_func(batch):
feature = []
label = []
n_labels = 33
for i, j in batch:
feature.append(i)
label.append(j)
feature, sentence_sq = DataProcess.pad_sentence(feature)
feature, uttr_sq, sentence_sq = DataProcess.pad_utterance(feature, sentence_sq)
label = DataProcess.change_label_shape(label, n_labels)
return bt
在 2020年4月9日 +0800 AM9:25,cynthia <[email protected]>,写道:
… > I found the reason why GPU load is so low that the dataloader processes data so slowly and GPU is always waiting.
can you share your found ? I've been troubled by this problem too, the model and the tensors return is_cuda=True, still the GPU load is 0%.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub, or unsubscribe.
|
@kenny1109 thanks, it's very nice of you |
|
Try to run the code on GPU. But it seems still on CPU.
The text was updated successfully, but these errors were encountered: