当前位置:网站首页>【问题解决】同一机器上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中调用的函数修改为:
边栏推荐
猜你喜欢

C1认证之web基础知识及习题——我的学习笔记

System design. How to design a spike system (full version transfer)
![[Evaluation model] Topsis method (pros and cons distance method)](/img/e7/c24241faced567f3e93f6ff3f20074.png)
[Evaluation model] Topsis method (pros and cons distance method)

8.03 Day34---BaseMapper query statement usage

Grain Mall - Basics (Project Introduction & Project Construction)

npm安装依赖报错npm ERR! code ENOTFOUNDnpm ERR! syscall getaddrinfonpm ERR! errno ENOTFOUND

Cannot read properties of null (reading ‘insertBefore‘)

Teenage Achievement Hackers Need These Skills

企业需要知道的5个 IAM 最佳实践

解决错误:npm WARN config global `--global`, `--local` are deprecated
随机推荐
C Expert Programming Chapter 5 Thinking about Linking 5.1 Libraries, Linking and Loading
day13--postman接口测试
3面头条,花7天整理了面试题和学习笔记,已正式入职半个月
Can‘t connect to MySQL server on ‘localhost3306‘ (10061) 简洁明了的解决方法
Dynamic programming of the division of numbers
[Evaluation model] Topsis method (pros and cons distance method)
8款最佳实践,保护你的 IaC 安全!
嵌入式系统驱动初级【4】——字符设备驱动基础下_并发控制
redis中常见的面试题
应届生软件测试薪资大概多少?
Landing, the IFC, GFC, FFC concept, layout rules, forming method, use is analysed
企业需要知道的5个 IAM 最佳实践
在被面试官说了无数次后,终于潜下心来整理了一下JVM的类加载器
DataTable使用Linq进行分组汇总,将Linq结果集转化为DataTable
el-Select 选择器 底部固定
npm安装依赖报错npm ERR! code ENOTFOUNDnpm ERR! syscall getaddrinfonpm ERR! errno ENOTFOUND
获取单选框选中内容
Delphi-C端有趣的菜单操作界面设计
数的划分之动态规划
C Expert Programming Chapter 5 Thinking about Linking 5.3 5 Special Secrets of Library Linking