question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

When I run the Usage demo

import torch
from torch2trt import torch2trt
from torchvision.models.alexnet import alexnet

# create some regular pytorch model...
model = alexnet(pretrained=True).eval().cuda()

# create example data
x = torch.ones((1, 3, 224, 224)).cuda()

# convert to TensorRT feeding sample data as input
model_trt = torch2trt(model, [x])

An error occurs:

AttributeError                            Traceback (most recent call last)
~/Documents/github/fast-reid/demo/convert2trt.py in <module>
----> 1 model_trt = torch2trt(model_alex, [x])

~/anaconda3/envs/detect2/lib/python3.6/site-packages/torch2trt-0.2.0-py3.6.egg/torch2trt/torch2trt.py in torch2trt(module, inputs, input_names, output_names, log_level, max_batch_size, fp16_mode, max_workspace_size, strict_type_constraints, keep_network, int8_mode, int8_calib_dataset, int8_calib_algorithm, int8_calib_batch_size, use_onnx, **kwargs)
    546             ctx.mark_outputs(outputs, output_names)
    547 
--> 548     builder.max_workspace_size = max_workspace_size
    549     builder.fp16_mode = fp16_mode
    550     builder.max_batch_size = max_batch_size

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

What is the problem? Many thanks!

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:19
  • Comments:13

github_iconTop GitHub Comments

42reactions
troellkecommented, Oct 28, 2021

TensorRT API was updated in 8.0.1 so you need to use different commands now. As stated in their release notes “ICudaEngine.max_workspace_size” and “Builder.build_cuda_engine()” among other deprecated functions were removed. (see https://docs.nvidia.com/deeplearning/tensorrt/release-notes/tensorrt-8.html#rel_8-0-1)

The current usage that worked for me:

  • to set max_workspace_size

config = builder.create_builder_config() config.max_workspace_size = 1 << 28

-and to build engine:

plan = builder.build_serialized_network(network, config) engine = runtime.deserialize_cuda_engine(plan)

18reactions
cheadriancommented, May 14, 2021

Got the same error when running using TensorRT Python 8.0.0.3. With nvidia-tensorrt-7.2.3.4 it works fine. !pip install nvidia-tensorrt==7.2.* --index-url https://pypi.ngc.nvidia.com

Read more comments on GitHub >

github_iconTop Results From Across the Web

AttributeError: 'tensorrt.tensorrt.Builder' object has no ...
Hello My project needs to use tensorrt7 with components but component which i installed always get version 8 I try to use this...
Read more >
Python Examples of tensorrt.Builder
This page shows Python examples of tensorrt.Builder. ... (parser.plugin_factory_ext is a write-only attribute) parser.plugin_factory_ext = fc_factory ...
Read more >
AttributeError: 'tensorrt.tensorrt.Builder' object has no ...
AttributeError : 'tensorrt.tensorrt.Builder' object has no attribute 'max_workspace_size' ... 1、错误:AttributeError: 'tensorrt.tensorrt.
Read more >
Module 'Tensorrt' Has No Attribute 'Logger'
TensorRT :AttributeError: 'module' object has no attribute 'Logger' ... Builder' object has no attribute 'maxworkspacesize' solution to this problem is to ...
Read more >
module 'tensorrt' has no attribute 'Logger'
I can NOT import trt.Builder() also. Python version is 3.6.7. Output of "dpkg -l | grep nvinfer" which gives Tensor RT version :...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found