baidu / DDParser

百度开源的依存句法分析系统
Apache License 2.0
973 stars 163 forks source link

不支持CPU版本的PaddlePaddle #54

Open fuhaogreat opened 2 years ago

fuhaogreat commented 2 years ago

使用CPU版本的PaddlePaddle时,会报以下错误

In [6]: ddp.parse(["百度是一家高科技公司"])
e[37m---    Fused 0 subgraphs into layer_norm op.e[0m
e[37m---    fused 4 pairs of fc gru patternse[0m
c:\users\31882\.conda\envs\demo\lib\site-packages\paddle\fluid\dygraph\math_op_patch.py:251: UserWarning: The dtype of left and right variables are not the same, left dtype is paddle.int32, but right dtype is paddle.bool, the right dtype will convert to paddle.int32
  warnings.warn(
c:\users\31882\.conda\envs\demo\lib\site-packages\paddle\fluid\dygraph\math_op_patch.py:251: UserWarning: The dtype of left and right variables are not the same, left dtype is paddle.float32, but right dtype is paddle.bool, the right dtype will convert to paddle.float32
  warnings.warn(
c:\users\31882\.conda\envs\demo\lib\site-packages\paddle\fluid\dygraph\math_op_patch.py:251: UserWarning: The dtype of left and right variables are not the same, left dtype is paddle.float32, but right dtype is paddle.int32, the right dtype will convert to paddle.float32
  warnings.warn(
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-6-27f0375642fc> in <module>
----> 1 ddp.parse(["百度是一家高科技公司"])

c:\users\31882\.conda\envs\demo\lib\site-packages\ddparser\run.py in parse(self, inputs)
    397             sequential_sampler=True if not self.args.buckets else False,
    398         )
--> 399         pred_arcs, pred_rels, pred_probs = epoch_predict(self.env, self.args, self.model, dataset.loader)
    400
    401         if self.args.buckets:

c:\users\31882\.conda\envs\demo\lib\site-packages\decorator.py in fun(*args, **kw)
    230             if not kwsyntax:
    231                 args, kw = fix(args, kw, sig)
--> 232             return caller(func, *(extras + args), **kw)
    233     fun.__name__ = func.__name__
    234     fun.__doc__ = func.__doc__

c:\users\31882\.conda\envs\demo\lib\site-packages\paddle\fluid\dygraph\base.py in __impl__(func, *args, **kwargs)
    274         def __impl__(func, *args, **kwargs):
    275             with _switch_tracer_mode_guard_(is_train=False):
--> 276                 return func(*args, **kwargs)
    277
    278         return __impl__(func)

c:\users\31882\.conda\envs\demo\lib\site-packages\ddparser\parser\model.py in epoch_predict(env, args, model, loader)
    199         rels.extend(layers.split(nn.masked_select(rel_preds, mask), lens.numpy().tolist()))
    200         if args.prob:
--> 201             arc_probs = nn.index_sample(layers.softmax(s_arc, -1), layers.unsqueeze(arc_preds, -1))
    202             probs.extend(
    203                 layers.split(

c:\users\31882\.conda\envs\demo\lib\site-packages\paddle\fluid\layers\nn.py in softmax(input, use_cudnn, name, axis)
   1335
   1336     if in_dygraph_mode():
-> 1337         return _C_ops.softmax(input, 'axis', axis, 'use_cudnn', use_cudnn)
   1338
   1339     inputs = {"X": [input]}

ValueError: (InvalidArgument) softmax(): argument (position 4) must be bool, but got int (at C:\home\workspace\Paddle_release\paddle/fluid/pybind/op_function.h:260)

可以修复一下吗,感谢

zhangyimi commented 2 years ago

可以检查下ddparser是否是最新版本以及paddle的版本是否为2.0以上

LeonG7 commented 2 years ago

我的版本:paddlepaddle cpu版本的安装2.1.3,gpu版本安装2.3.1的,ddparser安装1.0.6版本。https://github.com/baidu/DDParser/issues/57