当前位置:网站首页>【问题解决】同一机器上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中调用的函数修改为:
边栏推荐
- 注意!软件供应链安全挑战持续升级
- 力扣:746. 使用最小花费爬楼梯
- sql server如何得到本条记录与上一条记录的差异,即变动值
- 7.18 Day23----标记语言
- Chapter 5 C programming expert thinking 5.4 alert Interpositioning of links
- The Road to Ad Monetization for Uni-app Mini Program Apps: Full Screen Video Ads
- 基于gRPC编写golang简单C2远控
- npm安装依赖报错npm ERR! code ENOTFOUNDnpm ERR! syscall getaddrinfonpm ERR! errno ENOTFOUND
- Landing, the IFC, GFC, FFC concept, layout rules, forming method, use is analysed
- el-Select 选择器 底部固定
猜你喜欢
随机推荐
What are the steps for how to develop a mall system APP?
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.5 数组和指针的其他区别
Redis common interview questions
去重的几种方式
Cannot read properties of null (reading ‘insertBefore‘)
渗透测试(PenTest)基础指南
7.18 Day23----标记语言
As soon as flink cdc is started, the CPU of the source Oracle server soars to more than 80%. What is the reason?
leetcode 12. Integer to Roman numeral
OpenSSF 安全计划:SBOM 将驱动软件供应链安全
Resolved error: npm WARN config global `--global`, `--local` are deprecated
The 2022 PMP exam has been delayed, should we be happy or worried?
DP4398:国产兼容替代CS4398立体声24位/192kHz音频解码芯片
What is the salary of a software testing student?
C Expert Programming Chapter 5 Thinking about Chaining 5.6 Take it easy --- see who's talking: take the Turning quiz
The symbol table
About yolo7 and gpu
[Cocos] cc.sys.browserType可能的属性
2023年PMP考试会用新版教材吗?回复来了!
2022年PMP考试延迟了,该喜该忧?









