yanwii / seq2seq

基于Pytorch的中文聊天机器人 集成BeamSearch算法
Apache License 2.0
241 stars 87 forks source link

RuntimeError: cuda runtime error (59) : #21

Closed liutianling closed 5 years ago

liutianling commented 5 years ago

在问答集中增加问题后,就报了这个错误。 我就改了这几个参数 self.input_size = 1840 self.output_size = 1840 self.hidden_size = 64 self.max_length = 50 /pytorch/torch/lib/THCUNN/ClassNLLCriterion.cu:57: void cunn_ClassNLLCriterion_updateOutput_kernel(Dtype , Dtype , Dtype , long , Dtype , int, int, int, int, long) [with Dtype = float, Acctype = float]: block: [0,0,0], thread: [0,0,0] Assertion t >= 0 && t < n_classes failed. THCudaCheck FAIL file=/pytorch/torch/lib/THC/generic/THCTensorCopy.c line=18 error=59 : device-side assert triggered Traceback (most recent call last): File "seq2seq.py", line 443, in seq.retrain() File "seq2seq.py", line 434, in retrain self.train() File "seq2seq.py", line 213, in train loss, logits = self.step(inputs, targets, self.max_length) File "seq2seq.py", line 253, in step decoder_output, decoder_context, decoder_hidden, decoder_attention = self.decoder(decoder_input, decoder_context, decoder_hidden, encoder_outputs) File "/home/liuyong/venv/seq2seq-master/lib/python3.5/site-packages/torch/nn/modules/module.py", line 224, in call result = self.forward(input, *kwargs) File "seq2seq.py", line 105, in forward attn_weights = self.attn(rnn_output.squeeze(0), encoder_outputs) File "/home/liuyong/venv/seq2seq-master/lib/python3.5/site-packages/torch/nn/modules/module.py", line 224, in call result = self.forward(input, **kwargs) File "seq2seq.py", line 63, in forward if USE_CUDA: attn_energies = attn_energies.cuda() File "/home/liuyong/venv/seq2seq-master/lib/python3.5/site-packages/torch/autograd/variable.py", line 279, in cuda return CudaTransfer.apply(self, device_id, async) File "/home/liuyong/venv/seq2seq-master/lib/python3.5/site-packages/torch/autograd/_functions/tensor.py", line 151, in forward return i.cuda(async=async) File "/home/liuyong/venv/seq2seq-master/lib/python3.5/site-packages/torch/_utils.py", line 66, in _cuda return newtype(self.size()).copy(self, async)

yanwii commented 5 years ago

试着把output_size调大一点

liutianling commented 5 years ago

@yanwii 谢谢,确实要调大点。 关于提高问答准确度的问题: 1、分词与否,预测时回答的合理性有没有影响 2、哪些手段可以(包括数据的预处理)可以使对话更加合理? 谢谢。。。

yanwii commented 5 years ago

1.在中文nlp任务中,大部分任务用分词的特征结果都会比不分词的效果好 2.这个模型依赖大量数据。如果要做机器人,光有这个模型是不够的,因为它属于推断模型,结果太不可控了。

liutianling commented 5 years ago

@yanwii 非常感谢你的详细解答,谢谢。