I have an internal error with the engine.cpp as you can see below

[visualPerception-1] 1: Unexpected exception vector::_M_range_check: n (which is 5522) >= this->size() (which is 2) [visualPerception-1] 3: Get binding is input failed.
[visualPerception-1] 1: Unexpected exception vector::_M_range_check: [visualPerception-1] 3: Get binding data type failed.
_n (which is 5523) >= this->size() (which is 2)
[visual Perception-1] 3: [engine.cpp::getBindingDimensions::1268] Error Code 3: Internal Error (Parameter check failed at: runtime/api/engine.cpp::getBind ingDimensions::1268, condition: bindIndex >= 0 && bindIndex < getNbBindings() [visualPerception-1].

I will also provide a useful part of the code.

// I insert two more arguments in the infer function to identify which camera makes infer, and another argument that set the  total number of cameras
bool YoloExecutionContext::infer(void* inputData, int numberOfDevices) {
    auto& mEngine = context->getEngine();
    // copy input host buffers to input device buffers
    int batch_size = mEngine.getMaxBatchSize(); 
    assert(batch_size >= n_tiles_w * n_tiles_h * numberOfDevices);
    for (int i = 0; i < mEngine.getNbBindings(); i++) { 
        if (mEngine.bindingIsInput(i)) {
            mHostBuffers[i] = inputData;
            void* dstPtr = mDeviceBuffers[i];
            void* srcPtr = mHostBuffers[i];
            DataType dtype = mEngine.getBindingDataType(i);
            assert(dtype == DataType::kFLOAT);
            int dsize = dtype_size(dtype);
            
            size_t byteSize = volume(mEngine.getBindingDimensions(i)) * dsize * n_tiles_h * n_tiles_w * numberOfDevices; // probably the best assertion of byteSize variable 
            cudaMemcpyAsync(dstPtr, srcPtr, byteSize, cudaMemcpyHostToDevice, stream);
        }
    }   
    context->setOptimizationProfile(0);

    //context->setBindingDimensions(0, Dims4{n_tiles_w * n_tiles_h * numberOfDevices, 3, this->width, this->height}); // first argument is the optimization profile
    context->setBindingDimensions(0, Dims3{3, this->height, this->width});
    
    //bool status = context->executeV2(mDeviceBindings.data());
    bool status = context->execute(n_tiles_w * n_tiles_h * numberOfDevices, mDeviceBindings.data());
    
    if (!status) {
        cout << "Failed to execute inference" << endl;
        return false;
    }   

    // copy output device buffers to output host buffers
    for (int i = 0; i < mEngine.getNbBindings(); i++) {
        if (!mEngine.bindingIsInput(i)) {
            void* dstPtr = mHostBuffers[i];
            void* srcPtr = mDeviceBuffers[i];
            DataType dtype = mEngine.getBindingDataType(i);
            assert(dtype == DataType::kFLOAT);
            int dsize = dtype_size(dtype);
            size_t byteSize = volume(mEngine.getBindingDimensions(i)) * dsize * n_tiles_w * n_tiles_h * numberOfDevices;
            cudaMemcpyAsync(dstPtr, srcPtr, byteSize, cudaMemcpyDeviceToHost, stream);
        }
    }
    cudaStreamSynchronize(stream);
    return true;
}


Could you help me resove it. Also the current versions of cuda are 11.4 and for tensorrt 8.2, and cudNN version 8.2 .

Hi @aquajim03 ,
Can you please share the command you are using to run teh script.
Also, the h/w details

Thanks

1 Like

Our GPU is GTX 1650 4GB and the script is part of the execution context of a yoloV5 that we are integrating in our code. To run the script (basically the entire perception) we use a ros2 launch command which more specifically is:

ros2 launch package_name launch_file_name 

where the package name is the name of the repo we created for the integration and launch_file_name is an xml.
Also in the process of building the code there is no issue.
(Note that 7 months ago that we had to use the code for a competition the error didn’t appear after multiple sudo reboot of the internal SSD disk.)