当前位置:网站首页>【问题解决】同一机器上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中调用的函数修改为:
边栏推荐
- MySQL数据库面试题总结(2022最新版)
- How to view sql execution plan offline collection
- Resolved error: npm WARN config global `--global`, `--local` are deprecated
- What are the functions of mall App development?
- 9、动态SQL
- DataTable使用Linq进行分组汇总,将Linq结果集转化为DataTable
- FPGA学习笔记——知识点总结
- C专家编程 第5章 对链接的思考 5.4 警惕Interpositioning
- 4.3 基于注解的声明式事务和基于XML的声明式事务
- LCP 17. 速算机器人
猜你喜欢

字节最爱问的智力题,你会几道?

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)

Tactile intelligent sharing - SSD20X realizes upgrade display progress bar

8、自定义映射resultMap

The idea setting recognizes the .sql file type and other file types

MySQL数据库面试题总结(2022最新版)

px、em、rem的区别

腾讯136道高级岗面试题:多线程+算法+Redis+JVM
随机推荐
嵌入式系统驱动初级【4】——字符设备驱动基础下_并发控制
C Expert Programming Chapter 4 The Shocking Fact: Arrays and Pointers Are Not the Same 4.3 What is a Declaration and What is a Definition
基于gRPC编写golang简单C2远控
力扣题解8/3
[One step in place] Jenkins installation, deployment, startup (complete tutorial)
入坑软件测试的经验与建议
Towards Real-Time Multi-Object Tracking(JDE)
败给“MySQL”的第60天,我重振旗鼓,四面拿下蚂蚁金服offer
The idea setting recognizes the .sql file type and other file types
About yolo7 and gpu
Chapter 5 C programming expert thinking 5.4 alert Interpositioning of links
C语言 -- 操作符详解
【云原生--Kubernetes】Pod资源管理与探针检测
C专家编程 第4章 令人震惊的事实:数组和指针并不相同 4.1 数组并非指针
npm init [email protected] 构建项目报错SyntaxError: Unexpected token ‘.‘解决办法
CentOS7 - yum install mysql
Will the 2023 PMP exam use the new version of the textbook?Reply is here!
《看见新力量》第四期免费下载!走进十五位科技创业者的精彩故事
Cannot read properties of null (reading ‘insertBefore‘)
使用Loadrunner进行性能测试