【Debug】TensorRT报错汇总

搭建TensorRT过程参见:【通俗易懂】Windows系统安装TensorRT
下面是运行中的问题汇总及解决。

报错1. No module named ‘pycuda’

解决:

pip install pycuda

报错2. AttributeError: ‘tensorrt.tensorrt.Builder’ object has no attribute ‘max_workspace_size’

报错3. AttributeError: ‘tensorrt.tensorrt.Builder’ object has no attribute ‘fp16_mode’

报错4.AttributeError: ‘tensorrt.tensorrt.Builder’ object has no attribute ‘int8_mode’

报错5. AttributeError: ‘tensorrt.tensorrt.Builder’ object has no attribute ‘int8_calibrator’

报错6. AttributeError: ‘tensorrt.tensorrt.Builder’ object has no attribute ‘build_cuda_engine’

原因:上面三个都是版本问题:tensorrt8.0以上max_workspace_size、fp16、int8_mode、int8_calibrator、int8_calibrator、build_cuda_engine等属性都不在builder里面了,配置分离,需要为builder建一个config来管理属性配置。
解决

# 新增代码,一般放到builder定义的后面,不知道builder在哪定义可以ctrl+f搜一下,或者按着ctrl点击builder变量会跳转到定义处。
config = builder.create_builder_config()

# 报错2来源:
# builder.max_workspace_size = 1 << 20
# 改为:
config.max_workspace_size = 1 << 20

# 报错3来源:
# builder.fp16_mode = fp16_mode
# 改为:
config.set_flag(trt.BuilderFlag.FP16)

# 报错4来源:
# builder.int8_mode = int8_mode
# 改为:
config.set_flag(trt.BuilderFlag.INT8)

# 报错5来源:
# builder.int8_calibrator = Calibrator(calibration_stream, calibration_table_path)
# 改为:
config.int8_calibrator = Calibrator(calibration_stream, calibration_table_path)

# 报错6来源:
# engine = builder.build_cuda_engine(network)
# 改为:
engine = builder.build_engine(network, config)

以上是在TensorRT过程中遇到的问题,量化亲测已解决。
我真是说的太详细了,各位看管可否给个赞支持一下呢.

  • 8
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值