AttributeError: 'tensorrt_bindings.tensorrt.Builder' object has no attribute 'set_calibration_profile'
时间: 2023-06-22 17:41:45 浏览: 199
2,app_att.c文件说明1
I apologize for the confusion. The `set_calibration_profile()` method was introduced in TensorRT 7.0. If you are using an earlier version of TensorRT, you can set the optimization profile using the `set_shape()` method on the input tensor of the network. Here is an example:
```python
import tensorrt as trt
# Create a builder object
builder = trt.Builder(trt.Logger(trt.Logger.INFO))
# Create a network object
network = builder.create_network()
# Add layers to the network
...
# Get the input tensor of the network
input_tensor = network.get_input(0)
# Set the input shape for the optimization profile
profile = builder.create_optimization_profile()
profile.set_shape(input_tensor.name, (1, 3, 224, 224), (8, 3, 224, 224), (4, 3, 224, 224))
builder.set_optimization_profile(profile)
# Build the engine
engine = builder.build_cuda_engine(network)
```
In this example, we create a network object and add layers to it. We then get the input tensor of the network using `network.get_input(0)`. We create an optimization profile using `builder.create_optimization_profile()`, and set the input shape for the profile using `profile.set_shape()`. We set the optimization profile for the builder using `builder.set_optimization_profile()`, and then build the engine using `builder.build_cuda_engine(network)`.
Note that the `set_shape()` method takes three arguments: the minimum shape, the maximum shape, and the preferred shape. You can adjust these shapes to suit your network's requirements.
阅读全文