当前位置:网站首页>【问题解决】同一机器上Flask部署TensorRT报错记录
【问题解决】同一机器上Flask部署TensorRT报错记录
2022-08-04 05:24:00 【ifsun-】
1.报错:UserWarning: volatile was removed and now has no effect. Use `with torch.no_grad():` instead.
image = Variable(image, volatile=True)
解决办法:
with torch.no_grad():
image = Variable(image)
2.报错:TypeError: Object of type int64 is not JSON serializable
原代码:
r = {"label": label, "label name": label_name,
"probability": float(prob)}
是由于其中的label默认int类型,json库不认识。
解决办法:手动转为字符串类型。
label = str(label)
3.报错:pycuda._driver.LogicError: explicit_context_dependent failed: invalid device context - no currently active context?
网上都说是由于pycuda.driver没有初始化,导致无法得到context,需要在导入pycuda.driver后再导入pycuda.autoinit。即:
import pycuda.driver as cuda
import pycuda.autoinit
但我的代码中有这两行。而且单独执行tensorrt推理过程,也就是不引入flask时,是不会报错的,所以考虑可能是flask服务器在请求进来时会产生新的进程导致的。
参考:https://www.coder.work/article/352714
解决办法:将flask中调用的函数修改为:
边栏推荐
- 9. Dynamic SQL
- Gartner 权威预测未来4年网络安全的8大发展趋势
- 擎朗智能全国研发创新中心落地光谷:去年曾获2亿美元融资
- Programming hodgepodge (4)
- 《看见新力量》第四期免费下载!走进十五位科技创业者的精彩故事
- 部署LVS-DR群集【实验】
- Web Basics and Exercises for C1 Certification - My Study Notes
- npm init [email protected] 构建项目报错SyntaxError: Unexpected token ‘.‘解决办法
- C Expert Programming Chapter 5 Thinking about Linking 5.1 Libraries, Linking and Loading
- 9、动态SQL
猜你喜欢
7.16 Day22---MYSQL(Dao模式封装JDBC)
idea设置识别.sql文件类型以及其他文件类型
4.3 Annotation-based declarative transactions and XML-based declarative transactions
Shocked, 99.9% of the students didn't really understand the immutability of strings
SLSA 框架与软件供应链安全防护
day13--postman interface test
字节最爱问的智力题,你会几道?
The idea setting recognizes the .sql file type and other file types
MySQL日志篇,MySQL日志之binlog日志,binlog日志详解
The symbol table
随机推荐
[C language advanced] program environment and preprocessing
The symbol table
8款最佳实践,保护你的 IaC 安全!
npm报错Beginning October 4, 2021, all connections to the npm registry - including for package installa
MySQL日志篇,MySQL日志之binlog日志,binlog日志详解
编程大杂烩(四)
应届生软件测试薪资大概多少?
使用Loadrunner进行性能测试
Delphi-C端有趣的菜单操作界面设计
【评价类模型】Topsis法(优劣解距离法)
【云原生--Kubernetes】Pod资源管理与探针检测
处理List<Map<String, String>>类型
sql server如何得到本条记录与上一条记录的差异,即变动值
C Expert Programming Chapter 4 The Shocking Fact: Arrays and pointers are not the same 4.4 Matching declarations to definitions
有趣的 Kotlin 0x0E:DeepRecursiveFunction
【一步到位】Jenkins的安装、部署、启动(完整教程)
编程大杂烩(三)
Uni-app 小程序 App 的广告变现之路:全屏视频广告
LCP 17. 速算机器人
败给“MySQL”的第60天,我重振旗鼓,四面拿下蚂蚁金服offer