Flat-Lattice-Transformer 复现,附带数据集(Weibo、Resume、MSRA)

使用fastNLP(0.5.0)时报错:There is no usable gpu. set device as cpu or None.

在复现论文Flat-Lattice-Transformer的时候,按照源代码:https://github.com/LeeSureman/Flat-Lattice-Transformer 的要求安装fastNLP==0.5.0的版本,但是还是存在问题,当在CPU的机器上跑代码的时候会报以下错误:

ValueError: There is no usable gpu. set device as cpu or None.

虽然已经配置了CPU:

parser.add_argument('--device', default='cpu')

此时需要修改fastNLP的源码,
在此路径下:

C:\Users\lx\AppData\Local\Programs\Python\Python38\Lib\site-packages\fastNLP\core\utils.py

将该目录下的.py文件226-228行改为:


        if not torch.cuda.is_available() and ((isinstance(device, str) and device != 'cpu') or
                                              (isinstance(device, torch.device) and device.type != 'cpu')):
            raise ValueError("There is no usable gpu. set device as cpu or None.")

就ok了,但由于cpu还是跑不起来:

RuntimeError: [enforce fail at ..\c10\core\CPUAllocator.cpp:75] data. DefaultCPUAllocator: not enough memory: you tried to allocate 325140480 bytes. Buy new RAM!

居然建议我换RAM。(还是老老实实在服务器上跑吧,本地只是验证该程序的可行性)

ps:
处理好的Weibo数据集:
链接:https://pan.baidu.com/s/1QfWukFze_modzz3vo9cWBw
提取码:hell

处理好的Resume数据集:
链接:https://pan.baidu.com/s/1p8YgbZgXdedHzfNpn5ntrg
提取码:hell

处理好的MSRA数据集:
链接:https://pan.baidu.com/s/1WrNf3CGqA3pFCnG-3AlTow
提取码:hell

Original: https://blog.csdn.net/weixin_43429393/article/details/117366006
Author: 学习飞的菜鸟
Title: Flat-Lattice-Transformer 复现,附带数据集(Weibo、Resume、MSRA)

原创文章受到原创版权保护。转载请注明出处:https://www.johngo689.com/531806/

转载文章受原作者版权保护。转载请注明原作者出处!

(0)

大家都在看

亲爱的 Coder【最近整理,可免费获取】👉 最新必读书单  | 👏 面试题下载  | 🌎 免费的AI知识星球