text-cnn icon indicating copy to clipboard operation
text-cnn copied to clipboard

run text_test.py时候出现问题

Open weilongheal opened this issue 6 years ago • 17 comments

报这个错的同时出现OOM, ResourceExhaustedError: OOM when allocating tensor with shape[10000,256,1,596] and type float on /job:localhost/replica:0/task:0/device:GPU:0 by allocator GPU_0_bf, 请帮忙看看,

weilongheal avatar Sep 10 '18 09:09 weilongheal

Caused by op 'cnn/conv/conv1d/Conv2D', defined at: File "text_test.py", line 74, in model = TextCNN(config) File "/root/tensorflow/text_model.py", line 44, in init self.cnn() File "/root/tensorflow/text_model.py", line 52, in cnn conv= tf.layers.conv1d(embedding_inputs, self.config.num_filters, self.config.kernel_size, name='conv')

weilongheal avatar Sep 10 '18 09:09 weilongheal

出现“ResourceExhaustedError”一般是说超出内存了,应该是你的词表,内存支撑不了

cjymz886 avatar Sep 10 '18 09:09 cjymz886

但是我跑的是你用来的测试的那个数据集,词表是5000,应该没问题的吧,

weilongheal avatar Sep 10 '18 09:09 weilongheal

你可以把vocab_size调小测试看看,是不是这个问题

cjymz886 avatar Sep 10 '18 09:09 cjymz886

不行,我是在GPU上跑的,vocab_size设置成3000还是同样的错误;我运行 text-rnn-cnn那个的时候值用了一个GPU,也没有遇到这个问题,现在vocab_size设置3000,4个GPU还是这个错误,所以我觉得不应该是内存的问题.

报错是这个: conv= tf.layers.conv1d(embedding_inputs, self.config.num_filters, self.config.kernel_size, name='conv') 但是,我看着是没有问题的呀,train 没问题,test遇到问题了,

weilongheal avatar Sep 10 '18 09:09 weilongheal

感谢大佬解答,

weilongheal avatar Sep 10 '18 09:09 weilongheal

很奇怪的是,如果我指定CPU进行test的时候,很快,而且可以正常运行,

weilongheal avatar Sep 10 '18 10:09 weilongheal

代码是在cpu环境跑的,gpu我没试过,可能跟这个有关系吧

cjymz886 avatar Sep 10 '18 11:09 cjymz886

代码在GPU上出错,前面有朋友也提出这个问题,能否修正一下?

agilelab avatar Oct 10 '18 09:10 agilelab

代码在GPU上出错,前面有朋友也提出这个问题,能否修正一下?

cjymz886 avatar Oct 10 '18 09:10 cjymz886

代码在GPU上出错,前面有朋友也提出这个问题,能否修正一下?

非常感谢分享这样高质量的项目

agilelab avatar Oct 10 '18 10:10 agilelab

代码在GPU上出错,前面有朋友也提出这个问题,能否修正一下?

非常感谢分享这样高质量的项目

我在GPU环境完成了测试,我是正常跑完的,我的GPU是16G,程序跑的时候用了约15G,你所出现的错误,我觉得应是GPU大小的问题;网上对这类错误的处理,说是将batch_size减少,我测试过将batch_size从64变为32,但发现程序运行时耗用的GPU大小并没有变化,具体在你们环境我就不能十分确定了;我建议还是切换到CPU下跑,训练的速度也是很快的。

我目前能做的就是这么多了,若有问题,我们再探讨。

cjymz886 avatar Oct 12 '18 01:10 cjymz886

请问我用cnn做句子分类为什么训练词向量时报RuntimeError: you must first build vocabulary before training the model,训练模型时报ValueError: zero-size array to reduction operation maximum which has no identity,是不能用您的代码做句子分类么?希望可以尽快得到您的回复 @cjymz886

Qinshimingyue23 avatar Jul 27 '19 03:07 Qinshimingyue23

你好,代码是可以做句子分类的。你的第一个问题,我不敢肯定,是不是你的语料库太少了,将word2vec的mincout参数设置为1,试试;第二问题,我也不能特别确定,感觉是某个步骤的tensor可能出现问题

------------------ 原始邮件 ------------------ 发件人: "Qinshimingyue23"[email protected]; 发送时间: 2019年7月27日(星期六) 中午11:28 收件人: "cjymz886/text-cnn"[email protected]; 抄送: "烛之文"[email protected];"Mention"[email protected]; 主题: Re: [cjymz886/text-cnn] run text_test.py时候出现问题 (#1)

请问我用cnn做句子分类为什么训练词向量时报RuntimeError: you must first build vocabulary before training the model,训练模型时报ValueError: zero-size array to reduction operation maximum which has no identity,是不能用您的代码做句子分类么?希望可以尽快得到您的回复 @cjymz886

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

cjymz886 avatar Jul 29 '19 08:07 cjymz886

我的语料库很少,就200多条,但是min_cout初始值就等于1啊,是不是其他参数也要改一下

Qinshimingyue23 avatar Jul 30 '19 02:07 Qinshimingyue23

具体我不太好说,我也没碰到这样的情况,你语料库很少,感觉就不用去word2vec训练,直接初始化就可以

------------------ 原始邮件 ------------------ 发件人: "Qinshimingyue23"[email protected]; 发送时间: 2019年7月30日(星期二) 上午10:29 收件人: "cjymz886/text-cnn"[email protected]; 抄送: "烛之文"[email protected];"Mention"[email protected]; 主题: Re: [cjymz886/text-cnn] run text_test.py时候出现问题 (#1)

我的语料库很少,就200多条,但是min_cout初始值就等于1啊,是不是其他参数也要改一下

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.

cjymz886 avatar Jul 30 '19 03:07 cjymz886

好的,谢谢

------------------ 原始邮件 ------------------ 发件人: "Darral"[email protected]; 发送时间: 2019年7月30日(星期二) 中午11:06 收件人: "cjymz886/text-cnn"[email protected]; 抄送: "秦时明月"[email protected];"Comment"[email protected]; 主题: Re: [cjymz886/text-cnn] run text_test.py时候出现问题 (#1)

具体我不太好说,我也没碰到这样的情况,你语料库很少,感觉就不用去word2vec训练,直接初始化就可以

------------------ 原始邮件 ------------------ 发件人: "Qinshimingyue23"[email protected]; 发送时间: 2019年7月30日(星期二) 上午10:29 收件人: "cjymz886/text-cnn"[email protected]; 抄送: "烛之文"[email protected];"Mention"[email protected]; 主题: Re: [cjymz886/text-cnn] run text_test.py时候出现问题 (#1)

我的语料库很少,就200多条,但是min_cout初始值就等于1啊,是不是其他参数也要改一下

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread. — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

Qinshimingyue23 avatar Jul 30 '19 03:07 Qinshimingyue23