RuntimeError: Already borrowed
问题:
之前写的SBERT模型接口部署上线后最近报了RuntimeError: Already borrowed的错误,在这里记录下。
现象:
具体的报错如下:
File "/home/XXXX/XXX/src/sentence_proc.py", line 77, in compute_sentence_vectors
sentences = self.tokenizer(sentences, padding='max_length', truncation=True, max_length=self.max_seq_length,return_tensors="tf")
File "/home/XXX/.local/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 2249, in __call__
return self.batch_encode_plus(
File "/home/XXXX/.local/lib/python3.8/site-packages/transformers/tokenization_utils_base.py", line 2434, in batch_encode_plus
return self._batch_encode_plus(
File "/home/XXXX/.local/lib/python3.8/site-packages/transformers/tokenization_utils_fast.py", line 370, in _batch_encode_plus
self.set_truncation_and_padding(
File "/home/XXXX/.local/lib/python3.8/site-packages/transformers/tokenization_utils_fast.py", line 326, in set_truncation_and_padding
self._tokenizer.enable_truncation(max_length, stride=stride, strategy=truncation_strategy.value)
RuntimeError: Already borrowed
讨论:
网上关于这个问题的讨论:https://ask.csdn.net/questions/6983340 ;大致讨论的原因是因为多线程下使用了同一个tokenizer导致的。
因为使用的是huggingface的transformers项目,所以在项目的issues上也看到了这个问题:https://github.com/huggingface/transformers/issues/10434 ;这里面提供的解决方案是使用TFREcord进行数据的转换,再通过文件流的方式读入pipline。
但是最后通过测试,因为是在进行批量问句进行相似计算调用的时候会报错,而且是发生在大批量的时候,当批大小减少到模型训练时batch_size以下时正常调用,所以在服务内对批量数据进行了切分处理,并没有尝试上面的解决方法。
RuntimeError: Already borrowed相关推荐
- RuntimeError: Expected object of backend CUDA but got backend CPU for argument
RuntimeError: Expected object of backend CUDA but got backend CPU for argument #4 'mat1' 原因:变量没有加cud ...
- RuntimeError: Expected object of device type cuda but got device type cpu for argument pytorch数据位置
RuntimeError: Expected object of device type cuda but got device type cpu for argument #2 'target' i ...
- RuntimeError: Assertion cur_target 0 cur_target n_classes failed
问题描述 使用pytorch的函数 torch.nn.CrossEntropyLoss()计算Loss时报错: RuntimeError: Assertion `cur_target >= 0 ...
- hnswlib RuntimeError: Cannot return the results in a contigious 2D array. Probably ef or M is to sma
1. 问题现象 index = hnswlib.Index(space = '100', dim = 512) index.init_index(max_elements = 100, ef_cons ...
- python导入matplotlib出错_解决导入matplotlib的RuntimeError: Python is not installed as a framework....
import matplotlib.pyplot as plt 报错: RuntimeError: Python is not installed as a framework. The Mac OS ...
- RuntimeError: each element in list of batch should be of equal size
RuntimeError: each element in list of batch should be of equal size 示例代码: import os import re from t ...
- RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future rel
RuntimeError: Integer division of tensors using div or / is no longer supported, and in a future rel ...
- 迭代var()内置函数的时候出现RuntimeError: dictionary changed size during iteration的解决办法...
下午看了Mr Seven的教学视频,其中有一段讲全局变量的视频,迭代输出全局变量的时候报错了. 视频中的做法: for k,v in vars().items():print(k) 打印结果 for ...
- xshell virt-manager RuntimeError: could not open display
使用xshell连接到linux主机,使用virt-manager命令调用kvm的管理界面,结果 [root@instructor ~]# virt-manager Traceback (most r ...
最新文章
- 【深度学习】模型训练过程可视化思路(可视化工具TensorBoard)
- java:不同数据类型的转换规则
- vmware中的Ubuntu安装ssh全家桶(解决connect to host localhost port 22: Connection refused)...
- 将 iOS 应用的体积控制在 20MB 以内对于其下载量有很明显的影响吗?
- java quartz 2.2.3_java – Spring 3 Quartz 2错误
- opengl计算帧率_或许是迄今为止第一篇讲解 fps 计算原理的文章吧
- excel range 判断日期型_EXCEL常用函数二
- 2020-08-09
- IP核授权形式:软核、固核和硬核
- 【无人机】【2011.04】【含源码】四旋翼无人机的仿真与控制
- 阿里云商标注册怎么样?附上申请步骤流程
- DDos/DoS工具集(持续更新)
- [系统安全] 反病毒与免杀原理概论
- 6.misc类设备与蜂鸣器驱动
- oracle中间人投毒漏洞,‘TNS Listener’远程数据投毒漏洞
- mongodb-报错FailedToParse: Password must be URL Encoded for mongodb:// URL:
- 微信小程序之获取用户地址
- 电脑端微信dat文件怎么打开
- Hadoop+hive+flask+echarts大数据可视化之系统数据收集
- 贝叶斯例题(一)先验分布与后验分布