Hierarchical-attention-networks-pytorch icon indicating copy to clipboard operation
Hierarchical-attention-networks-pytorch copied to clipboard

No works on GPU

Open houpingx opened this issue 6 years ago • 9 comments

Try to run the code on GPU. But it seems still on CPU.

houpingx avatar Mar 07 '19 16:03 houpingx

me too

wwyi1828 avatar Aug 01 '19 21:08 wwyi1828

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

uvipen avatar Aug 28 '19 06:08 uvipen

Doesn't run on GPU for me as well, only CPU. I tried both ways, calling .cuda() and .to('cuda') on the model and the tensors, no success.

The model and the tensors return is_cuda=True, still the GPU load is close to 0% and CPU load is 100%.

TuringTrain avatar Nov 19 '19 16:11 TuringTrain

I found the reason why GPU load is so low that the dataloader processes data so slowly and GPU is always waiting.

kenny1109 avatar Jan 11 '20 15:01 kenny1109

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%.

cindyhi avatar Apr 09 '20 01:04 cindyhi

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%

cindyhi avatar Apr 09 '20 01:04 cindyhi

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 avatar Apr 09 '20 02:04 kenny1109

@kenny1109 thanks, it's very nice of you

cindyhi avatar Apr 09 '20 12:04 cindyhi

@kenny1109 did you slove that problem,i met the same problem

yongchaoyan avatar Jul 28 '20 09:07 yongchaoyan