Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

undefined reference to `cudnnCreate'



  • Hi,

    I am new to CUDNN and I just wrote few lines but the problem is even they are not getting compiled. I double checked everything with cudNN. I am on ubuntu 20.04 LTS, using latest QT, cuda 11.2 and cudnn 8.*.

    Problem is I am getting underfined references. For example cudnnCreate

    cudnnHandle_t cudnn;
      CUDNN_CALL(cudnnCreate(&cudnn));
    
    #define CUDA_CALL(f) { \
      cudaError_t err = (f); \
      if (err != cudaSuccess) { \
        std::cout \
            << "    Error occurred: " << err << std::endl; \
        std::exit(1); \
      } \
    }
    

    Below is my pro file.

    QT -= gui
    
    CONFIG += c++14 console
    CONFIG -= app_bundle
    CONFIG -= qml_debug
    #CONFIG += release
    OBJECTS_DIR=obj
    
    # The following define makes your compiler emit warnings if you use
    # any Qt feature that has been marked deprecated (the exact warnings
    # depend on your compiler). Please consult the documentation of the
    # deprecated API in order to know how to port your code away from it.
    DEFINES += QT_DEPRECATED_WARNINGS
    
    # You can also make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    # You can also select to disable deprecated APIs only up to a certain version of Qt.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    SOURCES +=
    
    INCLUDEPATH += /home/sher/dco-intervals/dco_cpp_dev/src/
    #LIBS += /home/sher/NAG/dcl6i33ngl/lib/libdcoc.a
    
    QMAKE_CXXFLAGS += -fPIC
    
    unix|win32: LIBS += -ljsoncpp
    
    CUDNN_PATH = /usr/local/cuda-11.2
    INCLUDEPATH += -I $$(CUDNN_PATH)/include
    LIBS += -L $$(CUDNN_PATH)/lib64 -L/usr/local/lib
    
    QMAKE_CXXFLAGS_RELEASE += -Ofast -march=native
    QMAKE_CXXFLAGS_DEBUG += -g -O0
    
    QMAKE_LFLAGS_DEBUG += -g -O0
    QMAKE_LFLAGS_RELEASE += -Ofast
    
    
    CUDA_DIR      = /usr/local/cuda-11.2
    INCLUDEPATH  += $$CUDA_DIR/include
    QMAKE_LIBDIR += $$CUDA_DIR/lib64
    LIBS += -lcudart -lcuda
    
    
    
    # Path to cuda SDK install
    macx:CUDA_DIR = /Developer/NVIDIA/cuda-11.2
    linux:CUDA_DIR = /usr/local/cuda-11.2
    # Path to cuda toolkit install
    macx:CUDA_SDK = /Developer/NVIDIA/cuda-11.2/samples
    linux:CUDA_SDK = /usr/local/cuda-11.2/samples
    
    #Cuda include paths
    INCLUDEPATH += $$CUDA_DIR/include
    INCLUDEPATH += $$CUDA_DIR/common/inc/
    INCLUDEPATH += $$CUDA_DIR/../shared/inc/
    
    
    
    
    #cuda libs
    macx:QMAKE_LIBDIR += $$CUDA_DIR/lib
    linux:QMAKE_LIBDIR += $$CUDA_DIR/lib64
    QMAKE_LIBDIR += $$CUDA_SDK/common/lib
    #note for dynamic parallelism you need libcudadevrt
    LIBS += -lcudart -lcudadevrt
    QMAKE_CXXFLAGS+= -fopenmp # and pass this option to the linker when linking the project
        QMAKE_LFLAGS += -fopenmp -Ofast -march=native
    # join the includes in a line
    CUDA_INC = $$join(INCLUDEPATH,' -I','-I',' ')
    
    # Define output directories
    DESTDIR = "/home/sher/CU_KERNEL"
    OBJECTS_DIR = "/home/sher/CU_KERNEL/OBJ"
    CUDA_OBJECTS_DIR = "/home/sher/CU_KERNEL"
    CUDA_SOURCES += \
    convolution.cu \
    
    #-DCUDNN_INCLUDE_DIR=path/to/cudnn/include -DCUDNN_LIBRARY=path/to/cudnn/lib64/libcudnn.so
    # include paths
    INCLUDEPATH += $$CUDA_DIR/include \
                   $$CUDA_SDK/common/inc/ \
                   $$CUDA_SDK/../shared/inc/
    INCLUDEPATH += /dclin34nn/include/
    INCLUDEPATH += /home/sher/boostlib/include/
    INCLUDEPATH += /home/sher/CU_KERNEL/
    
    
    # library directories
    QMAKE_LIBDIR += $$CUDA_DIR/lib/$$SYSTEM_NAME \
                    $$CUDA_SDK/common/lib/$$SYSTEM_NAME \
                    $$CUDA_SDK/../shared/lib/$$SYSTEM_NAME
    
    LIBS += -lcuda -lcudart
    LIBS += $$CUDA_LIBS
    NVCCFLAGS = --compiler-options -fno-strict-aliasing -use_fast_math --ptxas-options=-v
    
    # Configuration of the Cuda compiler
    CONFIG(debug, debug|release) {
        # Debug mode
        cuda_d.input = CUDA_SOURCES
        cuda_d.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
        cuda_d.commands = $$CUDA_DIR/bin/nvcc -D_DEBUG  $$CUDA_INC $$NVCCFLAGS $$NVCC_LIBS --machine 64 --default-stream per-thread -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
        cuda_d.dependency_type = TYPE_C
        QMAKE_EXTRA_COMPILERS += cuda_d
    
    }
    else {
        # Release mode
        cuda.input = CUDA_SOURCES
        cuda.output = $$CUDA_OBJECTS_DIR/${QMAKE_FILE_BASE}_cuda.o
        cuda.commands = $$CUDA_DIR/bin/nvcc  $$CUDA_INC $$NVCCFLAGS $$NVCC_LIBS --machine 64 --default-stream per-thread -c -o ${QMAKE_FILE_OUT} ${QMAKE_FILE_NAME}
        cuda.dependency_type = TYPE_C
        QMAKE_EXTRA_COMPILERS += cuda
    
    }
    
    DISTFILES += \
    
    
    

  • Lifetime Qt Champion

    I don't see where you link against the cudnn library which contains this symbol afaics from asking google.



  • @Christian-Ehrlicher Solved I didn't link -lcudnn it earlier. Now it's working.


Log in to reply