当前位置:网站首页>RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`问题解决
RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`问题解决
2022-07-07 02:18:00 【不撸先疯。】
一、问题描述
使用transformers包调用pytorch框架的Bert预训练模型时,使用正常的bert-base-cased在其他数据集上正常运行,但是运用Roberta的时候却一直报错:RuntimeError: CUDA error: CUBLAS_STATUS_ALLOC_FAILED when calling `cublasCreate(handle)`
忙活了好几天也没查出是什么错误,网上一直提醒batch_size是否太大导致,修改为16->8->4->2都没有用。
通过与其他数据集的对比,发现我在tokenizer中加入了新的special_token,导致可能报错了!
二、问题解决
在原始的tokenizer中加入special_tokens时,忘记将model的tokenizer的词表进行更新导致!
完整更新方式为:
from transformers import BertTokenizer, BertModel
tokenizer = BertTokenizer.from_pretrained('bert-base-cased')
# 添加特殊词
tokenizer.add_special_tokens({'additional_special_tokens':["<S>"]})
model = BertModel.from_pretrained("bert-base-cased")
# 在模型中更新词表的大小!
# 重要!
model.resize_token_embeddings(len(tokenizer))
三、问题解决
可以通过,开始训练!
边栏推荐
- Apache ab 压力测试
- Niuke Xiaobai monthly race 52 E. sum logarithms in groups (two points & inclusion and exclusion)
- Navicat importing 15g data reports an error [2013 - lost connection to MySQL server during query] [1153: got a packet bigger]
- How can I check the DOI number of a foreign document?
- docker-compose启动redis集群
- 【解决】Final app status- UNDEFINED, exitCode- 16
- 2022Android面试必备知识点,一文全面总结
- 怎样查找某个外文期刊的文献?
- Learning notes | data Xiaobai uses dataease to make a large data screen
- What books can greatly improve programming ideas and abilities?
猜你喜欢
Shared memory for interprocess communication
Leite smart home longhaiqi: from professional dimming to full house intelligence, 20 years of focus on professional achievements
Open the blue screen after VMware installation
POI导出Excel:设置字体、颜色、行高自适应、列宽自适应、锁住单元格、合并单元格...
matlab / ENVI 主成分分析实现及结果分析
[GNN] graphic gnn:a gender Introduction (including video)
What books can greatly improve programming ideas and abilities?
Linear algebra (1)
How to install swoole under window
Software testing knowledge reserve: how much do you know about the basic knowledge of "login security"?
随机推荐
VIM mapping large K
Developers don't miss it! Oar hacker marathon phase III chain oar track registration opens
JWT 认证
地质学类比较有名的外文期刊有哪些?
PostgreSQL database timescaledb function time_ bucket_ Gapfill() error resolution and license replacement
Test the foundation of development, and teach you to prepare for a fully functional web platform environment
UIC(组态UI工程)公版文件库新增7款行业素材
K8s running Oracle
Navicat导入15G数据报错 【2013 - Lost connection to MySQL server during query】 【1153:Got a packet bigger】
Wechat applet hides the progress bar component of the video tag
直击2022ECDC萤石云开发者大会:携手千百行业加速智能升级
C language (structure) defines a user structure with the following fields:
缓存在高并发场景下的常见问题
Overview of FlexRay communication protocol
Implementation of VGA protocol based on FPGA
"Parse" focalloss to solve the problem of data imbalance
What books can greatly improve programming ideas and abilities?
「解析」FocalLoss 解决数据不平衡问题
Abnova 膜蛋白脂蛋白体技术及类别展示
POI export to excel: set font, color, row height adaptation, column width adaptation, lock cells, merge cells