CUDNN, OpenCV, compile warning: "warning: overloaded virtual function "cv:: ..." is only partially overridden in class"

So i am able to compile and execute this C++ program,

#include <cudnn.h>
#include <iostream>
#include <opencv2/opencv.hpp>

cv::Mat load_image(const char* image_path){
    cv::Mat image = cv::imread(image_path);
    image.convertTo(image, CV_32FC3);
    cv::normalize(image, image, 0, 1, cv::NORM_MINMAX);
    return image;
}

int main(void){
    
    cudnnHandle_t cudnn;
    cudnnCreate(&cudnn);
    cv::Mat image = load_image("conure.jpg");

    return 0;

}

however i get these warnings.

I do not want to ignore these warnings, does anybody know how i can solve them?

Hi,

Not sure if this is due to openCV or not. Could you file a topic on openCV forum?

1 Like

This warning is only seen when compiling with NVCC, not with g++.
If you rename your file as .cpp instead of .cu and adjust the build command this wouldn’t happen.
You would use NVCC for compiling .cu files with pure CUDA code such as kernels, and use g++ for cpp files.

Thanks for you reply. If i do what you suggest, it seems like a can no longer use any CUDA-C++ methods. Does this mean that it is not possible to use CUDNN with CUDA-C++ ?

Here is the link;

You need to specify the libs you want to link against, such as:

-lcudnn -L$OPENCV_DIR/lib -lopencv_core -lopencv_imgcodecs -L/usr/local/cuda/lib64 -lcudart

Note that path to libs in non default locations would also have to be set in environment variable LD_LIBRARY_PATH for execution.

Thank you!! Finally got a clean compilation. So to clarify, when using the OpenCV library, the C++ file must be always saved as .cpp ? I’m not sure if this is the case because i have seen online tutorials where they use OpenCV with CUDA C++ in the .cu format.

Like this one; Convolutions with cuDNN – Peter Goldsborough

github for it is

1 Like