gpu训练配置下,crf_decoding_layer设置device=-1与否都会core
使用gpu训练一个LSTM-CRF模型,CRF解码层无论标识为CPU设备与否都会导致core
I0713 20:41:26.991703 15845 Util.cpp:130] Calling runInitFunctions
I0713 20:41:26.992059 15845 Util.cpp:143] Call runInitFunctions done.
[INFO 2017-07-13 20:41:27,173 networks.py:1466] The input order is [sent_char, sent_seg_flag, target]
[INFO 2017-07-13 20:41:27,173 networks.py:1472] The output order is [crf]
I0713 20:41:27.178159 15845 Trainer.cpp:170] trainer mode: Normal
*** Aborted at 1499949687 (unix time) try "date -d @1499949687" if you are using GNU date ***
PC: @ 0x6bb953 paddle::CRFDecodingLayer::init()
*** SIGSEGV (@0x20) received by PID 15845 (TID 0x7f55e9529840) from PID 32; stack trace: ***
@ 0x7f55e9104160 (unknown)
@ 0x6bb953 paddle::CRFDecodingLayer::init()
@ 0x625477 paddle::NeuralNetwork::init()
@ 0x61a131 paddle::MultiGradientMachine::MultiGradientMachine()
@ 0x63d75f paddle::GradientMachine::create()
@ 0x73fa5b paddle::TrainerInternal::init()
@ 0x73c510 paddle::Trainer::init()
@ 0x5b8a49 main
@ 0x7f55e7d21bd5 __libc_start_main
@ 0x5cdfa5 (unknown)
/home/aducz/paddle/paddle_internal_release_tools/idl/paddle/output/bin/paddle_local: line 109: 15845 Segmentation fault (core dumped) ${DEBUGGER} $MYDIR/../opt/paddle/bin/paddle_trainer ${@:2}
相关模型配置如下:
if not is_predict:
crf_l = crf_layer(
name='crf',
size=label_dict_len,
input=feat,
label=target,
param_attr=ParameterAttribute(
name='crfw', learning_rate=mix_hidden_lr))
crf_dec_l = crf_decoding_layer(
name='crf_dec_l',
size=label_dict_len,
input=feat,
label=target,
layer_attr=ExtraAttr(device=-1),
param_attr=ParameterAttribute(name='crfw'))
eval = sum_evaluator(input=crf_dec_l)
outputs(crf_l)
版本信息
PaddlePaddle 0.9.0, compiled with
with_avx: ON
with_gpu: ON
with_double: OFF
with_python: ON
with_rdma: OFF
with_glog: ON
with_gflags: ON
with_metric_learning:
with_timer: OFF
with_predict_sdk:
从以上贴出来的出错信息,暂时没办法直接判断出出错的原因。
- 从出错栈看,crf_decoding 层初始化时即报错。代码里这一层的初始化的逻辑很简单,解析配置,加载参数。怀疑是不是还是配置有问题。
- 您帖的这一段配置,看着是训练时候的配置,解码的配置是什么呢?
想起来有一点,CRF 这个层不支持 GPU,如果想使用GPU训练,需要将这一层单独指定,放在CPU下运算。
- 首先在启动训练任务时指定 paralell_nn = 1, 参见这一节:http://doc.paddlepaddle.org/release_doc/0.9.0/doc/ui/cmd_argument/detail_introduction.html#gpu
- 设置CRF层的device id = -1
不知是否与于此有关。
@lcy-seso 谢谢解答,你说的太对了。我就是缺少了paralell_nn = 1参数,没有这个参数,不能混合使用GPU和CPU,我设置的ExtraAttr(device=-1)没起作用。添加paralell_nn = 1就可以了。
--parallel_nn Whether to use multi-thread to calculate one neural network or not. If false, use gpu_id specify which gpu core to use (the device property in trainer config will be ingored). If true, the gpu core is specified in trainer config (gpu_id will be ignored). type: bool (default: 0).
不客气~ 如果您觉得问题得到解决的时候, 可以将 issue 关闭,如果有新的问题,我们可以在新的issue中讨论,谢谢啦 ~