yzhangcs / parser

:rocket: State-of-the-art parsers for natural language.
https://parser.yzhang.site/
MIT License
829 stars 141 forks source link

RuntimeError: cuda runtime error (59) #1

Closed xiaoxiaoAurora closed 5 years ago

xiaoxiaoAurora commented 5 years ago

Hello, I run your code locally when the code runs the training, validation, and testing correctly. But the following error occurs while running on the server: (Note: My data label category is 2)

THCudaCheck FAIL file=/pytorch/aten/src/THC/generic/THCTensorMath.cu line=26 error=59 : device-side assert triggered Traceback (most recent call last): File "run.py", line 112, in file=args.file) File "/home/workspace/dependency-parser/BiaffineAttention/biaffine/trainer.py", line 27, in fit self.train(train_loader) File "/home/workspace/dependency-parser/BiaffineAttention/biaffine/trainer.py", line 68, in train loss.backward() File "/home/miniconda3/lib/python3.6/site-packages/torch/tensor.py", line 93, in backward torch.autograd.backward(self, gradient, retain_graph, create_graph) File "/home/miniconda3/lib/python3.6/site-packages/torch/autograd/init.py", line 90, in backward allow_unreachable=True) # allow_unreachable flag RuntimeError: cuda runtime error (59) : device-side assert triggered at /pytorch/aten/src/THC/generic/THCTensorMath.cu:26 /pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:105: 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: [9,0,0] Assertion t >= 0 && t < n_classes failed. /pytorch/aten/src/THCUNN/ClassNLLCriterion.cu:105: 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: [10,0,0] Assertion t >= 0 && t < n_classes failed.

yzhangcs commented 5 years ago

I just ran the code and I did not get this error maybe you can refer to this issue(pytorch/pytorch#1204) to find a solution

xiaoxiaoAurora commented 5 years ago

Thank you! I found and solved this problem. In the classes of heads of the test data, there is a class setting to -1, so the above error occurred. In addition, I would like to know that your code reports the following error, and how can i solve it. Thank you very much !

Traceback (most recent call last): File "F:/workspace/dependency_parser/BiaffineAttention/run.py", line 112, in file=args.file) File "F:\workspace\dependency_parser\BiaffineAttention\biaffine\trainer.py", line 34, in fit loss, test_metric = self.evaluate(test_loader) File "E:\Anaconda3\lib\site-packages\torch\autograd\grad_mode.py", line 46, in decorate_no_grad return func(*args, **kwargs) File "F:\workspace\dependency_parser\BiaffineAttention\biaffine\trainer.py", line 85, in evaluate loss += self.model.get_loss(s_arc, s_lab, heads, labels, mask) File "F:\workspace\dependency_parser\BiaffineAttention\biaffine\parser.py", line 111, in get_loss s_lab = s_lab[torch.arange(len(s_arc)), heads] RuntimeError: index 1214 is out of bounds for dimension 1 with size 21

yzhangcs commented 5 years ago

Sorry, the code has not been completed yet and still needs to be improved:cry: Since I do not know which datasets you used, please note whether some configs have been modified correctly, such as the 'unk' token in pretrained embeddings And can you tell me the shape of these tensors

xiaoxiaoAurora commented 5 years ago

Sorry, the code has not been completed yet and still needs to be improved😢 Since I do not know which datasets you used, please note whether some configs have been modified correctly, such as the 'unk' token in pretrained embeddings And can you tell me the shape of these tensors

the data as the following:

1 我 我 3 2 终于 终于 3 3 写 写 12 4 完 完 3 5 了 了 3 6 这 这 7 7 篇文章 篇文章 3 8 , , 3 9 所以 所以 12 10 我 我 12 11 很 很 12 12 困 困 0 root 13 。 。 12 _

1 我 我 2 2 哥哥 哥哥 4 3 到底 到底 4 4 介绍 介绍 0 root 5 他 他 9 6 很 很 7 7 可爱 可爱 9 8 的 的 7 9 女朋友 女朋友 4 10 。 。 4 _

1 我 我 2 2 重视 重视 0 root 3 我们 我们 5 4 的 的 3 5 友谊 友谊 2 6 很 很 7 7 高 高 5 8 ! ! 2 _

1 谁 谁 6 2 想 想 6 3 跟 跟 4 4 我 我 6 5 一起 一起 6 6 去 去 10 7 我 我 10 8 就 就 10 9 一起 一起 10 10 去 去 0 root 11 谁 谁 12 。 。 10

1 我 我 2 2 相信 相信 0 root 3 , , 7 4 这种 这种 5 5 经验 经验 7 6 将 将 7 7 帮助 帮助 13 8 我 我 13 9 在 在 12 10 未来 未来 12 11 的 的 10 12 职业 职业 13 13 活动 活动 2 14 。 。 2 _

1 这家 这家 2 2 公司 公司 3 3 注册 注册 0 root 4 在 在 6 5 2014 2014 6 6 年 年 3 7 。 。 3 _

1 我们 我们 2 2 谈到 谈到 0 root 3 了 了 2 4 前景 前景 9 5 的 的 4 6 进一步 进一步 7 7 工作 工作 9 8 的 的 7 9 公司 公司 2 10 。 。 2 _

1 该 该 2 2 公司 公司 7 3 是 是 7 4 很 很 5 5 欢快 欢快 7 6 的 的 5 7 工作人员 工作人员 0 root 8 。 。 7 _

1 该 该 2 2 代表 代表 7 3 语言 语言 4 4 愉快 愉快 7 5 地 地 4 6 去 去 7 7 接触 接触 0 root 8 , , 11 9 是 是 11 10 非常 非常 11 11 友好 友好 7 12 。 。 7 _

1 我 我 4 2 真的 真的 4 3 很 很 4 4 喜欢 喜欢 0 root 5 在 在 6 6 实践 实践 9 7 中 中 6 8 的 的 6 9 公司 公司 4 10 。 。 4 _

1 第一天 第一天 3 2 我 我 3 3 会见 会见 0 root 4 了 了 3 5 老板 老板 3 6 , , 3 7 看到 看到 3 8 该 该 9 9 办公室 办公室 7 10 。 。 7 _

1 在 在 3 2 实习 实习 3 3 期间 期间 6 4 , , 3 5 我 我 6 6 进行 进行 0 root 7 各种类型 各种类型 9 8 的 的 7 9 工作 工作 6 10 。 。 6 _

1 他 他 2 2 相信 相信 0 root 3 在 在 4 4 未来 未来 2 5 , , 7 6 他 他 7 7 争取 争取 2 8 很 很 9 9 好 好 11 10 的 的 9 11 职务 职务 7 12 和 和 15 13 更 更 14 14 高 高 15 15 工资 工资 11 16 。 。 2 _

yzhangcs commented 5 years ago

Sorry, the code has not been completed yet and still needs to be improved😢 Since I do not know which datasets you used, please note whether some configs have been modified correctly, such as the 'unk' token in pretrained embeddings And can you tell me the shape of these tensors

the data as the following:

1 我 我 3 2 终于 终于 3 3 写 写 12 4 完 完 3 5 了 了 3 6 这 这 7 7 篇文章 篇文章 3 8 , , 3 9 所以 所以 12 10 我 我 12 11 很 很 12 12 困 困 0 root 13 。 。 12 _

1 我 我 2 2 哥哥 哥哥 4 3 到底 到底 4 4 介绍 介绍 0 root 5 他 他 9 6 很 很 7 7 可爱 可爱 9 8 的 的 7 9 女朋友 女朋友 4 10 。 。 4 _

1 我 我 2 2 重视 重视 0 root 3 我们 我们 5 4 的 的 3 5 友谊 友谊 2 6 很 很 7 7 高 高 5 8 ! ! 2 _

1 谁 谁 6 2 想 想 6 3 跟 跟 4 4 我 我 6 5 一起 一起 6 6 去 去 10 7 我 我 10 8 就 就 10 9 一起 一起 10 10 去 去 0 root 11 谁 谁 12 。 。 10

1 我 我 2 2 相信 相信 0 root 3 , , 7 4 这种 这种 5 5 经验 经验 7 6 将 将 7 7 帮助 帮助 13 8 我 我 13 9 在 在 12 10 未来 未来 12 11 的 的 10 12 职业 职业 13 13 活动 活动 2 14 。 。 2 _

1 这家 这家 2 2 公司 公司 3 3 注册 注册 0 root 4 在 在 6 5 2014 2014 6 6 年 年 3 7 。 。 3 _

1 我们 我们 2 2 谈到 谈到 0 root 3 了 了 2 4 前景 前景 9 5 的 的 4 6 进一步 进一步 7 7 工作 工作 9 8 的 的 7 9 公司 公司 2 10 。 。 2 _

1 该 该 2 2 公司 公司 7 3 是 是 7 4 很 很 5 5 欢快 欢快 7 6 的 的 5 7 工作人员 工作人员 0 root 8 。 。 7 _

1 该 该 2 2 代表 代表 7 3 语言 语言 4 4 愉快 愉快 7 5 地 地 4 6 去 去 7 7 接触 接触 0 root 8 , , 11 9 是 是 11 10 非常 非常 11 11 友好 友好 7 12 。 。 7 _

1 我 我 4 2 真的 真的 4 3 很 很 4 4 喜欢 喜欢 0 root 5 在 在 6 6 实践 实践 9 7 中 中 6 8 的 的 6 9 公司 公司 4 10 。 。 4 _

1 第一天 第一天 3 2 我 我 3 3 会见 会见 0 root 4 了 了 3 5 老板 老板 3 6 , , 3 7 看到 看到 3 8 该 该 9 9 办公室 办公室 7 10 。 。 7 _

1 在 在 3 2 实习 实习 3 3 期间 期间 6 4 , , 3 5 我 我 6 6 进行 进行 0 root 7 各种类型 各种类型 9 8 的 的 7 9 工作 工作 6 10 。 。 6 _

1 他 他 2 2 相信 相信 0 root 3 在 在 4 4 未来 未来 2 5 , , 7 6 他 他 7 7 争取 争取 2 8 很 很 9 9 好 好 11 10 的 的 9 11 职务 职务 7 12 和 和 15 13 更 更 14 14 高 高 15 15 工资 工资 11 16 。 。 2 _

just make sure that the 1,6,7 columns represent the words heads labels respectively

xiaoxiaoAurora commented 5 years ago

Sorry, the code has not been completed yet and still needs to be improved😢 Since I do not know which datasets you used, please note whether some configs have been modified correctly, such as the 'unk' token in pretrained embeddings And can you tell me the shape of these tensors

the data as the following: 1 我 我 3 2 终于 终于 3 3 写 写 12 4 完 完 3 5 了 了 3 6 这 这 7 7 篇文章 篇文章 3 8 , , 3 9 所以 所以 12 10 我 我 12 11 很 很 12 12 困 困 0 root 13 。 。 12 1 我 我 2 2 哥哥 哥哥 4 3 到底 到底 4 4 介绍 介绍 0 root 5 他 他 9 6 很 很 7 7 可爱 可爱 9 8 的 的 7 9 女朋友 女朋友 4 10 。 。 4 1 我 我 2 2 重视 重视 0 root 3 我们 我们 5 4 的 的 3 5 友谊 友谊 2 6 很 很 7 7 高 高 5 8 ! ! 2 1 谁 谁 6 2 想 想 6 3 跟 跟 4 4 我 我 6 5 一起 一起 6 6 去 去 10 7 我 我 10 8 就 就 10 9 一起 一起 10 10 去 去 0 root 11 谁 谁 12 。 。 10 1 我 我 2 2 相信 相信 0 root 3 , , 7 4 这种 这种 5 5 经验 经验 7 6 将 将 7 7 帮助 帮助 13 8 我 我 13 9 在 在 12 10 未来 未来 12 11 的 的 10 12 职业 职业 13 13 活动 活动 2 14 。 。 2 1 这家 这家 2 2 公司 公司 3 3 注册 注册 0 root 4 在 在 6 5 2014 2014 6 6 年 年 3 7 。 。 3 1 我们 我们 2 2 谈到 谈到 0 root 3 了 了 2 4 前景 前景 9 5 的 的 4 6 进一步 进一步 7 7 工作 工作 9 8 的 的 7 9 公司 公司 2 10 。 。 2 1 该 该 2 2 公司 公司 7 3 是 是 7 4 很 很 5 5 欢快 欢快 7 6 的 的 5 7 工作人员 工作人员 0 root 8 。 。 7 1 该 该 2 2 代表 代表 7 3 语言 语言 4 4 愉快 愉快 7 5 地 地 4 6 去 去 7 7 接触 接触 0 root 8 , , 11 9 是 是 11 10 非常 非常 11 11 友好 友好 7 12 。 。 7 1 我 我 4 2 真的 真的 4 3 很 很 4 4 喜欢 喜欢 0 root 5 在 在 6 6 实践 实践 9 7 中 中 6 8 的 的 6 9 公司 公司 4 10 。 。 4 1 第一天 第一天 3 2 我 我 3 3 会见 会见 0 root 4 了 了 3 5 老板 老板 3 6 , , 3 7 看到 看到 3 8 该 该 9 9 办公室 办公室 7 10 。 。 7 1 在 在 3 2 实习 实习 3 3 期间 期间 6 4 , , 3 5 我 我 6 6 进行 进行 0 root 7 各种类型 各种类型 9 8 的 的 7 9 工作 工作 6 10 。 。 6 1 他 他 2 2 相信 相信 0 root 3 在 在 4 4 未来 未来 2 5 , , 7 6 他 他 7 7 争取 争取 2 8 很 很 9 9 好 好 11 10 的 的 9 11 职务 职务 7 12 和 和 15 13 更 更 14 14 高 高 15 15 工资 工资 11 16 。 。 2

just make sure that the 1,6,7 columns represent the words heads labels respectively

That's great! Thank you very much for your answer, I found the reason, but for the time being did not think of a better solution to deal with this problem, thank you very much!