使用SentimentNet实现情感分类在ModelArts Notebook环境中可以执行,买同样的代码的本地执行可以会报错

Notebook镜像选择的mindspore1.7.0-cuda10.1-py3.7-ubuntu18.04,资源类型选择GPU,本地是mindspore1.8.1 CPU。

本地执行的代码是将mindspore_nlp_application.ipynb中的代码Cell组合在一起的,线上执行的也是mindspore_nlp_application.ipynb。

本地执行报错:

[mindspore/nn/layer/rnn_cells.py:69] LSTMCell has been changed from 'single LSTM layer' to 'single LSTM cell', if you still need use single LSTM layer, please use `nn.LSTM` instead. 

Traceback (most recent call last): 

  File "rnn_sample.py", line 461, in  

    batch_size=cfg.batch_size) 

  File "rnn_sample.py", line 425, in __init__ 

    dropout=0.0) 

  File "rnn_sample.py", line 361, in __init__ 

    dropout=dropout)) 

  File "/usr/local/lib/python3.7/dist-packages/mindspore/nn/layer/rnn_cells.py", line 73, in wrapper 

    raise ValueError(f"The arguments of `nn.LSTMCell` from old MindSpore version(<1.6) are detected, " 

ValueError: The arguments of `nn.LSTMCell` from old MindSpore version(<1.6) are detected, if you still need use single LSTM layer, please use `nn.LSTM` instead. 

Exception ignored in:  

Traceback (most recent call last): 

  File "/usr/local/lib/python3.7/dist-packages/mindspore/nn/cell.py", line 338, in __del__ 

    if self.compile_cache: 

  File "/usr/local/lib/python3.7/dist-packages/mindspore/nn/cell.py", line 329, in __getattr__ 

    raise AttributeError("The '{}' object has no attribute '{}'.".format(type(self).__name__, name)) 

AttributeError: The 'LSTMCell' object has no attribute 'compile_cache'. 

 貌似代码的版本太低造成的。可是Notebook的镜像是mindspore1.7.0,为什么可以执行呢?

****************************************************解答*****************************************************

因为不同版本之间是存在一些接口的变更的。比如脚本在1.7版本可以正常运行,1.8版本对一些接口做了变更,那么同样的脚本在1.8版本上可能就会报错。 还有就是一些算子对硬件的支持情况,比如有的算子仅支持GPU,那么在GPU上运行没有问题,在CPU上就会报错

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值