当前位置:网站首页>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))三、问题解决
可以通过,开始训练!

边栏推荐
- js装饰器@decorator学习笔记
- MySQL的安装
- 线性代数(一)
- 【从零开始】win10系统部署Yolov5详细过程(CPU,无GPU)
- 途家、木鸟、美团……民宿暑期战事将起
- 循环肿瘤细胞——Abnova 解决方案来啦
- Niuke Xiaobai monthly race 52 E. sum logarithms in groups (two points & inclusion and exclusion)
- 反射(二)
- [SOC FPGA] custom IP PWM breathing lamp
- Matlab / envi principal component analysis implementation and result analysis
猜你喜欢

地质学类比较有名的外文期刊有哪些?

线性代数(一)

Developers don't miss it! Oar hacker marathon phase III chain oar track registration opens
![[FPGA] EEPROM based on I2C](/img/28/f4f2efda4b5feb973c9cf07d9d908f.jpg)
[FPGA] EEPROM based on I2C
![[SOC FPGA] custom IP PWM breathing lamp](/img/4b/5053137cf95e851ca89057e9b9c15c.jpg)
[SOC FPGA] custom IP PWM breathing lamp

开发者别错过!飞桨黑客马拉松第三期链桨赛道报名开启
![[SOC FPGA] peripheral PIO button lights up](/img/34/58728bddbf91eb69e9c0062dbfd531.jpg)
[SOC FPGA] peripheral PIO button lights up

途家、木鸟、美团……民宿暑期战事将起

拼多多败诉:“砍价免费拿”侵犯知情权但不构成欺诈,被判赔400元

MySQL的安装
随机推荐
安装VMmare时候提示hyper-v / device defender 侧通道安全性
Party A's requirements for those who have lost 800 yuan
ICML 2022 | 探索语言模型的最佳架构和训练方法
反射(二)
JWT certification
线性代数(一)
BindingException 异常(报错)处理
C语言面试 写一个函数查找两个字符串中的第一个公共字符串
FlexRay通信协议概述
学习笔记|数据小白使用DataEase制作数据大屏
谷歌 Chrome 浏览器发布 103.0.5060.114 补丁修复 0-day 漏洞
[GNN] graphic gnn:a gender Introduction (including video)
Postgresql源码(59)分析事务ID分配、溢出判断方法
Markdown displays pictures side by side
What are the classic database questions in the interview?
PostgreSQL database timescaledb function time_ bucket_ Gapfill() error resolution and license replacement
二十岁的我4面拿到字节跳动offer,至今不敢相信
Three updates to build applications for different types of devices | 2022 i/o key review
程序员的日常 | 每日趣闻
LM11丨重构K线构建择时交易策略