当前位置:网站首页>【问题解决】同一机器上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中调用的函数修改为:
边栏推荐
猜你喜欢
随机推荐
你以为border-radius只是圆角吗?【各种角度】
JS基础--强制类型转换(易错点,自用)
day13--postman interface test
static在不同位置定义变量居然还有不同的含义?
DP4398:国产兼容替代CS4398立体声24位/192kHz音频解码芯片
Performance testing with Loadrunner
7.15 Day21---MySQL----索引
LCP 17. 速算机器人
DataTable uses Linq for grouping and summarization, and converts the Linq result set into DataTable
Grain Mall - Basics (Project Introduction & Project Construction)
9. Dynamic SQL
8.03 Day34---BaseMapper查询语句用法
JS basics - forced type conversion (error-prone, self-use)
MySQL日志篇,MySQL日志之binlog日志,binlog日志详解
力扣题解8/3
在被面试官说了无数次后,终于潜下心来整理了一下JVM的类加载器
System design. How to design a spike system (full version transfer)
string类简介
处理List<Map<String, String>>类型
渗透测试(PenTest)基础指南









