赞
踩
使用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 (
# device != 'cpu' or (isinstance(device, torch.device) and device.type != 'cpu')):
# raise ValueError("There is no usable gpu. set `device` as `cpu` or `None`.")
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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。