torch2trt报错no attribute‘max_workspace_size‘的解决方案(附文件)

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

torch2trt文件下载

链接:https://pan.baidu.com/s/1iclmKTPDqwNVq8LjPKITLw
提取码:c04e

问题背景

采用torch2trt进行pytorch的模型直接转换为trt模型,便于模型的部署。

报错内容

[TensorRT] INFO: [MemUsageChange] Init CUDA: CPU +287, GPU +0, now: CPU 2409, GPU 1144(MiB)
[TensorRT] WARNING: Tensor DataType is determined at build time for tensors not marked as input or output.
2022-08-09 19:48:27.038| ERROR    | __main__:<module>:77 - An error has been caught in function '', process 'MainProcess' (12166), thread 'MainThread' (140368472840000):
Traceback (most recent call last):

> File "tools/trt.py", line 77, in <module>
    main()<function main at 0x7f8f9f310950>

  File "tools/trt.py", line 62, in main
    max_workspace_size=(1 << 32),

  File "/home/local/lib/python3.6/site-packages/torch2trt-0.3.0-py3.6.egg/torch2trt/torch2trt.py", line 558, in torch2trt
    builder.max_workspace_size = max_workspace_size
    │                            └ 4294967296<tensorrt.tensorrt.Builder object at 0x7f8f94a50970>

AttributeError: 'tensorrt.tensorrt.Builder' object has no attribute 'max_workspace_size'

torch2trt报错no attribute‘max_workspace_size‘的解决方案(附文件)_第1张图片

解决方案

1、卸载torch2trt

pip3 uninstall torch2trt

2、安装相应插件

sudo apt install protobuf-compiler libprotoc-dev
pip3 install onnx==1.8.1
pip3 install onnx-simplifier

3、编译安装(文件见共享附件)

cd torch2trt
python3 setup.py

你可能感兴趣的:(Python,torch,tensorrt,pytorch,深度学习,人工智能)