NVIDIA / NVIDIA/TensorRT

my god ,some old api can not use , how to do in latest version

Open
#4,553 2 comments 0 reactions 1 assignee View on GitHub

@kevinch-nv is already working on this.

Since Aug 14, 2025.

Module:Documentation triaged
Dominant language
C++
Stars
13.4k
Forks
2.4k
Avg merge
5d 3h
Merged PRs (30d)
2

Description

HI,
I want to use tensorRT ,but only find old api, but in latest version not find. so I don't know how to operate tensorRT, do you have example or tutorial to help me ,thanks

    nvinfer1::ITensor *input = network->addInput("image", nvinfer1::DataType::kFLOAT, nvinfer1::Dims4(1, num_input, 1, 1));
    nvinfer1::Weights layer1_weight = make_weights(layer1_weight_values, 6);
    nvinfer1::Weights layer1_bias = make_weights(layer1_bias_values, 2);

    // 添加全连接层
    auto layer1 = network->addFullyConnected(*input, num_output, layer1_weight, layer1_bias);
    // 注意更严谨的写法是*(layer1->getOutput(0)) 即对getOutput返回的指针进行解引用
    auto prob = network->addActivation(*layer1->getOutput(0), nvinfer1::ActivationType::kSIGMOID);

    // 将prob标记为输出
    network->markOutput(*prob->getOutput(0));
    printf("Workspace Size = %.2f MB\n", (1 << 28) / 1024.0f / 1024.0f); // 256Mib
    config->setMaxWorkspaceSize(1 << 28);
    // 推理时 batchSize = 1
    builder->setMaxBatchSize(1);

where is the setMaxWorkspaceSize and setMaxBatchSize ?

where is getNbBindings getBindingName getBindingFormat bindingIsInput

        StringBuilder stringBuilder = new StringBuilder();
      
        stringBuilder.append("Name : ").append(iCudaEngine.getName()).append("\n");
        stringBuilder.append("Number of Bindings    : ").append(iCudaEngine.getNbBindings()).append("\n");
        for (int i = 0; i < iCudaEngine.getNbBindings(); i++) {
            stringBuilder.append("binding ").append("[").append(i).append("] :").append("\n");
            stringBuilder.append("   ").append("binding name: ").append(iCudaEngine.getBindingName(i)).append("\n");
            stringBuilder.append("   ").append("format      : ").append(iCudaEngine.getBindingFormat(i)).append("\n");
            if (iCudaEngine.bindingIsInput(i))
                stringBuilder.append("   ").append("is Input    :").append(true).append("\n");
        }
        
        stringBuilder.append("Max batch size    : ").append(iCudaEngine.getMaxBatchSize()).append("\n");
        stringBuilder.append("Device mem size   : ").append(iCudaEngine.getDeviceMemorySize()).append("\n");
        stringBuilder.append("Max Work Space    : ").append(iCudaEngine.getWorkspaceSize()).append("\n");

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.