当前位置:网站首页>【问题解决】同一机器上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中调用的函数修改为:
边栏推荐
- Shocked, 99.9% of the students didn't really understand the immutability of strings
- 力扣:509. 斐波那契数
- C语言 -- 操作符详解
- [Cloud Native--Kubernetes] Pod Resource Management and Probe Detection
- Teenage Achievement Hackers Need These Skills
- 8.03 Day34---BaseMapper query statement usage
- The difference between px, em, and rem
- [Evaluation model] Topsis method (pros and cons distance method)
- redis中常见的面试题
- 力扣:96.不同的二叉搜索树
猜你喜欢
随机推荐
处理List<Map<String, String>>类型
Write golang simple C2 remote control based on gRPC
Cannot read properties of null (reading ‘insertBefore‘)
编程大杂烩(三)
Tactile intelligent sharing - SSD20X realizes upgrade display progress bar
Gartner 权威预测未来4年网络安全的8大发展趋势
部署LVS-DR群集【实验】
应届生软件测试薪资大概多少?
flink cdc一启动,源端Oracle那台服务器的CPU就飙升到80%以上,会是啥原因呢?
9. Dynamic SQL
el-Select selector bottom fixed
C专家编程 第5章 对链接的思考 5.6 轻松一下---看看谁在说话:挑战Turning测验
Uni-app 小程序 App 的广告变现之路:全屏视频广告
Can‘t connect to MySQL server on ‘localhost3306‘ (10061) 简洁明了的解决方法
数的划分之动态规划
Chapter 5 C programming expert thinking 5.4 alert Interpositioning of links
【评价类模型】Topsis法(优劣解距离法)
redis中常见的面试题
C专家编程 第5章 对链接的思考 5.1 函数库、链接和载入
Redis common interview questions